Integrated circuit chip apparatus

ABSTRACT

Provided are an integrated circuit chip apparatus and a related product, the integrated circuit chip apparatus being used for executing a multiplication operation, a convolution operation or a training operation of a neural network. The present technical solution has the advantages of a small amount of calculation and low power consumption.

RELATED APPLICATION

The present application is a by-pass continuation application of PCTInternational Application No. PCT/CN2019/073453 filed Jan. 28, 2019, andfurther claims the benefit and priority of Chinese Patent ApplicationNo. 201711346333X, No. 2017113436421, No. 2017113474071, No.2017113477671, No. 2017113474067, No. 2017113474086, and No.2017113473100, each with the title of “Integrated Circuit Chip Apparatusand Product thereof” and filed on Feb. 14, 2017. The entire contents ofeach of the above-identified applications are incorporated herein byreference.

TECHNICAL FIELD

The present disclosure relates to the field of neural networkcomputation apparatus, and particularly relates to integrated circuitchip apparatus.

BACKGROUND

ANN (Artificial Neural Network) is a research focus emerged in 1980s inthe field of artificial intelligence. ANN abstracts the human brainneuron network from the perspective of information processing toestablish a simple model, and then builds different networks accordingto different connection methods. ANN is often referred to as neuralnetwork in engineering and academia. Neural networks are a type ofcomputational model. They are formed by a large number ofinterconnecting nodes (or may he referred to as neurons). Existingneural networks are based on CPU (Central Processing Unit) or GPU(Graphics Processing Unit) to realize neural network operations. Theoperations often require a large amount of computations and have highpower consumption.

SUMMARY

The present disclosure provides embodiments of an integrated circuitchip apparatus, a method performed using the same, and a processingapparatus having the same. Compared with existing integrated circuitchip apparatuses, the disclosed integrated circuit chip apparatus canreduce the amount of computations and power consumption.

An aspect of the disclosure provides an integrated circuit chipapparatus that may include a main processing circuit and a plurality ofbasic processing circuits. The main processing circuit or at least oneof the plurality of basic processing circuits may include a data typeconversion circuit configured to convert data between a floating pointdata type and a fixed point data type. The plurality of basic processingcircuits may be configured to perform a first set of neural networkcomputations in parallel on data transferred by the main processingcircuit, and transfer a plurality of computation results to the mainprocessing circuit. The main processing circuit may be configured toperform a second set of neural network computations in series on theplurality of computation results.

Another aspect of the disclosure provides a processing system that mayinclude a neural network computing apparatus, a general interconnectioninterface, and a general-purpose processing apparatus connected to theneural network computing apparat via the general interconnectioninterface. The neural network computing apparatus may further include amain processing circuit and a plurality of basic processing circuits.The main processing circuit or at least one of the plurality of basicprocessing circuits may include a data type conversion circuitconfigured to convert data between a floating point data type and afixed point data type. The plurality of basic processing circuits may beconfigured to perform a first set of neural network computations inparallel on data transferred by the main processing circuit, andtransfer a plurality of computation results to the main processingcircuit. The main processing circuit may be configured to perform asecond set of neural network computations in series on the plurality ofcomputation results.

A further aspect of the disclosure provides method for performing neuralnetwork operations using an integrated circuit chip apparatus that mayinclude a main processing circuit and a plurality of basic processingcircuits. The method may include converting data between a floatingpoint data type and a fixed point data type using a data type conversioncircuit in the main processing circuit or at least one of the basicprocessing circuits. The method may also include performing a first setof neural network computations in parallel on the data using theplurality of basic processing circuits to obtain a plurality ofcomputation results. The method may further include transferring theplurality of computation results from the plurality of basic processingcircuits to the main processing circuit. The method may additionallyinclude performing a second set of neural network computations in serieson the plurality of computation results using the main processingcircuit.

An additional aspect of the disclosure provides an integrated circuitchip apparatus that may include a main processing circuit, k branchcircuits connected to the main processing circuits, and k groups ofbasic processing circuits. Each group of basic processing circuits maybe connected to each branch circuit. Each branch processing circuit mayfurther include a data type conversion circuit configured to convertdata between a floating data type and a fixed point data type. The mainprocessing circuit may be configured to transfer data and a computationinstruction to the k branch circuits. The k branch circuits may beconfigured to forward the data transferred from the main processingcircuit to the k groups of basic processing circuits, and determinewhether to convert the data transferred between a fixed point data typeand a floating point data type using the data type conversion circuitsaccording to the type of the data transferred and the computationinstruction. The k groups of basic processing circuits may be configuredto perform a first set of neural network computations in parallel on thedata forwarded by the k branch circuits, and transfer computationresults to the main processing circuit through the k branch circuits.The main processing unit may be further configured to perform a secondset of neural network computations in series on the computation results.

Another aspect of the disclosure provides a processing system that mayinclude a neural network computing apparatus, a general interconnectioninterface, and a general-purpose processing apparatus connected to theneural network computing apparatus via the general interconnectioninterface. The neural network computing apparatus may further include amain processing circuit, k branch circuits connected to the mainprocessing circuits, and k groups of basic processing circuits. Eachgroup of basic processing circuits may be connected to each branchcircuit. Each branch processing circuit may further include a data typeconversion circuit configured to convert data between a floating datatype and a fixed point data type. The main processing circuit may beconfigured to transfer data and a computation instruction to the kbranch circuits. The k branch circuits may be configured to determinewhether to convert the data transferred between a fixed point data typeand a floating point data type using the data type conversion circuitsaccording to the type of the data transferred and the computationinstruction, and forward the data transferred from the main processingcircuit to the k groups of basic processing circuits. The k groups ofbasic processing circuits may be configured to perform a first set ofneural network computations in parallel on the data forwarded by the kbranch circuits, and transfer computation results to the main processingcircuit through the k branch circuits. The main processing circuit maybe further configured to perform a second set of neural networkcomputations in series on the computation results.

In another aspect, the disclosure provides a method for performingneural network operations using an integrated circuit chip apparatusthat may include a main processing circuit, k branch circuits connectedto the main processing circuit, and k groups of basic processingcircuits. Each group of basic processing circuits may be connected toeach branch circuit. The method may include transferring data and acomputation instruction from the main processing circuit to the k branchcircuits. The method may also include determining, by the k branchcircuits, whether to convert the data transferred between a fixed pointdata type and a floating point data type using the data type conversioncircuits according to the type of the data transferred and thecomputation instruction. The method may further include performing, bythe k groups of basic processing circuits, a first set of neural networkcomputations in parallel on the data forwarded by the k branch circuits.The method may additionally include transferring computation resultsfrom the k groups of basic processing circuits to the main processingcircuit through the k branch circuits. The method may also includeperforming, by the main processing circuit, a second set of neuralnetwork computations in series on the computation results.

In a further aspect, the disclosure provides an integrated circuit chipapparatus that may include a main processing circuit and a plurality ofbasic processing circuits, each including a data type conversioncomputational circuit configured to convert data between a floatingpoint data type and a fixed point data type. The main processing circuitmay be configured to perform a first set of neural network computationsin series, and transfer data and a computation instruction to theplurality of basic processing circuits. The plurality of basicprocessing circuits may be configured to determine whether to convertthe data transferred between the floating point data type and the fixedpoint data type using the data type conversion computational circuitsaccording to the type of data transferred the computation instruction,perform a second set of neural network computations in parallel on thedata transferred, and transfer computation results to the mainprocessing circuit.

In an additional aspect, the disclosure provides a processing systemthat may include a neural network computing apparatus, a generalinterconnection interface, and a general-purpose processing apparatusconnected to the neural network computing apparatus via the generalinterconnection interface. The neural network computing apparatus mayfurther include a main processing circuit and a plurality of basicprocessing circuits, each including a data type conversion computationalcircuit configured to convert data between a floating point data typeand a fixed point data type. The main processing circuit may beconfigured to perform a first set of neural network computations inseries, and transfer data and a computation instruction to the pluralityof basic processing circuits. The plurality of basic processing circuitsmay be configured to determine whether to convert the data transferredbetween the floating point data type and the fixed point data type usingthe data type conversion computational circuits according to the type ofdata transferred and the computation instruction, perform a second setof neural network computations in parallel on the data transferred, andtransfer computation results to the main processing circuit.

The disclosure provides, in an aspect, a method for performing neuralnetwork operations using an integrated circuit chip apparatus that mayinclude a main processing circuit, and a plurality of basic processingcircuits, each including a data type conversion computational circuitconfigured to convert data between a floating point data type and afixed point data type. The method may include transferring data and acomputation instruction from the main processing circuit to the basicprocessing circuits. The method may also include determining, by thebasic processing circuits, whether to convert the data transferredbetween a fixed point data type and a floating point data type using thedata type conversion computational circuits according to the type ofdata transferred and the computation instruction. The method may furtherinclude performing, by the basic processing circuits, a first set ofneural network computations in parallel on the data forwarded by the kbranch circuits. The method may additionally include transferringcomputation results from the basic processing circuits to the mainprocessing circuit. The method may also include performing, by the mainprocessing circuit, a second set of neural network computations inseries on the computation results.

The disclosure provides, in another aspect, an integrated circuit chipapparatus that may include a main processing circuit and a plurality ofbasic processing circuits arranged in a form of an ten array including mrows and n columns of basic processing circuits. Each basic processingcircuit may be connected to its adjacent basic processing circuits inthe array. The main processing circuit may be connected to k basicprocessing circuits of the plurality of basic processing circuitsarranged on one or more sides of the array. Each of the k basicprocessing circuits may include a data type conversion circuitconfigured to convert data between a floating point data type and afixed point data type. The main processing circuit may be configured totransfer data and a computation instruction to the k basic processingcircuits. The k basic processing circuits may be configured to determinewhether to convert the data transferred between the floating point datatype and the fixed point data type according to the type of the datatransferred and the computation instruction, and forward data receivedfrom the main processing circuit to the other basic processing circuitsamong the plurality of basic processing circuits. The plurality of basicprocessing circuits may be configured to perform a first set of neuralnetwork computations in parallel on the data transferred, and transfercomputation results to the main processing circuit through the k basicprocessing circuits. The main processing circuit may be furtherconfigured to perform a second set of neural network computations inseries on the computation results.

Then disclosure provides, in a further aspect, a processing system thatmay include a neural network computing apparatus, a generalinterconnection interface, and a general-purpose processing apparatusconnected to the neural network computing apparatus via the generalinterconnection interface. The neural network computing apparatus mayfurther include a main processing circuit and a plurality of basicprocessing circuits arranged in a form of an m*n array including m rowsand n columns of basic processing circuits. Each basic processingcircuit may be connected to its adjacent basic processing circuits inthe array. The main processing circuit may be connected to k basicprocessing circuits of the plurality of basic processing circuitsarranged on one or more sides of the array. Each of the k basicprocessing circuits may include a data type conversion circuitconfigured to convert data between a floating point data type and afixed point data type. The main processing circuit may be configured totransfer data and a computation instruction to the k basic processingcircuits. The k basic processing circuits may be configured to determinewhether to convert the data transferred between the floating point datatype and the fixed point data type according to the type of the datatransferred and the computation instruction, and forward data receivedfrom the main processing circuit to the other basic processing circuitsamong the plurality of basic processing circuits. The plurality of basicprocessing circuits may be configured to perform a first set of neuralnetwork computations in parallel on the data transferred, and transfercomputation results to the main processing circuit through the k basicprocessing circuits. The main processing circuit may be furtherconfigured to perform a second set of neural network computations inseries on the computation results.

The disclosure provides, in an additional aspect, a method forperforming neural network operations using an integrated circuit chipapparatus that may include a main processing circuit, and a plurality ofbasic processing circuits arranged in a form of an m*n array including mrows and n columns of basic processing circuits. Each basic processingcircuit may be connected to its adjacent basic processing circuits inthe array. The main processing circuit may be connected to k basicprocessing circuits of the plurality of basic processing circuitsarranged on one or more sides of the array. Each of the k basicprocessing circuits may include a data type conversion circuitconfigured to convert data between a floating point data type and afixed point data type. The method may include transferring data and acomputation instruction from the main processing circuit to the k basicprocessing circuits. The method may also include determining, by the kbasic processing circuits, whether to convert the data transferredbetween the fixed point data type and the floating point data type usingthe data type conversion circuits according to the type of datatransferred and the computation instruction. The method may furtherinclude forwarding, by the k basic processing circuits, data receivedfrom the main processing circuit to the other basic processing circuitsamong the plurality of basic processing circuits. The method mayadditionally include performing, by the plurality of basic processingcircuits, a first set of neural network computations in parallel on thedata forwarded by the k basic processing circuits. The method may alsoinclude transferring computation results to the main processing circuitthrough the k basic processing circuits. The method may further includeperforming, by the main processing circuit, a second set of neuralnetwork computations in series on the computation results.

An aspect of the disclosure provides an integrated circuit chipapparatus that may include a main processing circuit and a plurality ofbasic processing circuits arranged in a form of an m*n array thatincludes m rows and n columns of basic processing circuits. Each basicprocessing circuit may be connected to its adjacent basic processingcircuits in the array. The main processing circuit may be connected to kbasic processing circuits of the plurality of basic processing circuitsarranged on one or more sides of the array. The plurality of basicprocessing circuits may include data type conversion circuits configuredto convert data between a floating data type and a fixed point datatype. The main processing circuit may be configured to transfer data anda computation instruction to the k basic processing circuit. The k basicprocessing circuits may be configured to forward data received from themain processing circuit to the other basic processing circuits among theplurality of basic processing circuits. The plurality of basicprocessing circuits may be configured to determine whether to convertthe data transferred between the floating point data type and the fixedpoint data type according to the type of the data transferred and thecomputation instruction, perform a first set of neural networkcomputations in parallel on the data transferred, and transfercomputation results to the main processing circuit through the k basicprocessing circuits. The main processing circuit may be furtherconfigured to perform a second set of neural network computations inseries on the computation results.

Another aspect of the disclosure provides a processing system that mayinclude a neural network computing apparatus, a general interconnectioninterface, and a general-purpose processing apparatus connected to theneural network computing apparatus via the general interconnectioninterface. The neural network computing apparatus may further include amain processing circuit and a plurality of basic processing circuitsarranged in a form of an m*n array including in rows and n columns ofbasic processing circuits. Each basic processing circuit may beconnected to its adjacent basic processing circuits in the array. Themain processing circuit may be connected to k basic processing circuitsof the plurality of basic processing circuits arranged on one or moresides of the array. The plurality of basic processing circuits mayinclude data type conversion circuits configured to convert data betweena floating data type and a fixed point data type. The main processingcircuit may be configured to transfer data and a computation instructionto the k basic processing circuits. The k basic processing circuits maybe configured to forward data received from the main processing circuitto the other basic processing circuits among the plurality of basicprocessing circuits. The plurality of basic processing circuits may beconfigured to determine whether to convert the data transferred betweenthe floating point data type and the fixed point data type according tothe type of the data transferred and the computation instruction,perform a first set of neural network computations in parallel on thedata transferred, and transfer computation results to the mainprocessing circuit through the k basic processing circuits. The mainprocessing circuit may be further configured to perform a second set ofneural network computations in series on the computation results.

A further aspect of the disclosure provides a method for performingneural network operations using an integrated circuit chip apparatusthat may include a main processing circuit, and a plurality of basicprocessing circuits arranged in a form of an m*n array including m rowsand n columns of basic processing circuits. Each basic processingcircuit may be connected to its adjacent basic processing circuits inthe array. The main processing circuit may be connected to k basicprocessing circuits of the plurality of basic processing circuitsarranged on one or more sides of the array. The plurality of basicprocessing circuits may include data type conversion circuits configuredto convert data between a floating data type and a fixed point datatype. The method may include transferring data and a computationinstruction from the main processing circuit to the k basic processingcircuits. The method may also include forwarding, by the k basicprocessing circuits, data received from the main processing circuit tothe other basic processing circuits among the plurality of basicprocessing circuits. The method may further include determining, by theplurality of basic processing circuits, whether to convert the dataforwarded by the k basic processing circuits between the fixed pointdata type and the floating point data type using the data typeconversion circuits according to the type of data transferred and thecomputation instruction. The method may additionally include performing,by the plurality of basic processing circuits, a first set of neuralnetwork computations in parallel on the data forwarded. The method mayalso include transferring computation results to the main processingcircuit through the k basic processing circuits. The method may furtherinclude performing, by the main processing circuit, a second set ofneural network computations in series on the computation results.

An additional aspect of the disclosure provides a method for performinga neural network computation using an integrated circuit chip apparatus.The method may include receiving an operation instruction. The methodmay also include parsing the operation instruction to obtain input dataand weight data for a first computation. The method may further includedetermining a first complexity of the first computation according to theinput data, the weight data, and characteristics of the firstcomputation. The method may additionally include determining a firstdata type for the input data and the weight data in which the firstcomputation is to be performed according to the first complexity. Thefirst data type may be a floating point data type or a fixed point datatype. The method may also include performing the first computation onthe input data and the weight data in the first data type.

In an aspect, the disclosure provides an integrated circuit chipapparatus configured to perform a neural network computation. Theapparatus may include an external interface configured to receive afirst operation instruction. The apparatus may also include a processingcircuit configured to parse the first operation instruction to obtain afirst computation to be performed at a layer of the neural network andcorresponding input data and weight data for performing the firstcomputation, determine a first complexity of the first computationaccording to the input data, the weight data, and characteristics of thefirst computation, determine a first data type for the input data andthe weight data in which the first computation is to be performedaccording to the first complexity, wherein the first data type may be afloating point datatype or a fixed point data type, and perform thefirst computation on the input data and the weight data in the firstdata type.

In another aspect, the disclosure provides a processing apparatus thatmay include a neural network computing apparatus configured to perform aneural network computation of a neural network, a generalinterconnection interface, and a general-purpose processing apparatusconnected to the neural network computing apparatus via the generalinterconnection interface. The neural network computation apparatus maybe configured to receive input data and weight data for performing afirst computation, determine a first complexity of the first computationaccording to the input data, the weight data, and characteristics of thefirst computation, determine a first data type for the input data andthe weight data in which the first computation is to be performedaccording to the first complexity, wherein the first data type may be afloating point data type or a fixed point data type, and perform thefirst computation on the input data and the weight data in the firstdata type.

In a further aspect, the disclosure provides a method for training aneural network using an integrated circuit chip apparatus. The neuralnetwork may include a plurality of layers. The method may includereceiving a training instruction. The method may also includedetermining input data to the neural network and weight group data forthe respective layers according to the training instruction. The methodmay further include performing, by the integrated circuit chipapparatus, forward computations on the plurality of layers of the neuralnetwork using the input data and the weight group data to obtain inputdata and output data of the respective layers. The method mayadditionally include performing, by the integrated circuit chipapparatus, back computations on the plurality of layers of the neuralnetwork according to the training instruction to update the weight groupdata of the respective layers. Performing a first back computation on ann^(th) layer further may include determining a computation complexity ofthe first back computation to be performed on the n^(th) layer,determining a first data type in which the first back computation is tobe performed based on the computation complexity, wherein the first datatype may be a fixed point data type or a floating point data type,determining a weight group data gradient by performing the first backcomputation on the n^(th) layer in the first data type, and updating theweight group data of the n^(th) layer based on the weight group datagradient.

In additional aspect, the disclosure provides an integrated circuit chipapparatus configured to train a neural network. The neural network mayinclude a plurality of layers. The integrated circuit chip apparatus mayinclude an external interface configured to receive a traininginstruction and a processing circuit. The processing circuit may beconfigured to perform forward computations on the plurality of layers ofthe neural network according to the training instruction to obtain inputdata and output data of the respective layers and perform backcomputations on the plurality of layers of the neural network accordingto the training instruction to update the weight group data of therespective layers. To perform a first back computation on an n^(th)layer, the neural network computing apparatus may be configured todetermine a computation complexity of the first back computation to beperformed on the n^(th) layer, determine a first data type in which thefirst back computation is to be performed based on the computationcomplexity, wherein the first data type may be a fixed point data typeor a floating point data type, determine a weight group data gradient byperforming the first back computation on the n^(th) layer in the firstdata type, and update the weight group data of the n^(th) layer based onthe weight group data gradient n^(th) layer.

The disclosure provides, in an aspect, a processing apparatus that mayinclude a neural network computing apparatus configured to train aneural network, wherein the neural network may include a plurality oflayers, a general interconnection interface, and a general-purposeprocessing apparatus connected to the neural network computing apparatusvia the general interconnection interface. The neural network computingapparatus may be configured to perform forward computations on theplurality of layers of the neural network according to a traininginstruction to obtain input data and output data of the respectivelayers and perform back computations on the plurality of layers of theneural network according to the training instruction to update weightgroup data of the respective layers. To perform a first back computationon an n^(th) layer the neural network computing apparatus may beconfigured to determine a computation complexity of the first backcomputation to be performed on the n^(th) layer, determine a first datatype in which the first back computation is to be performed based on thecomputation complexity, wherein the first data type may be a fixed pointdata type or a floating point data type, determine a weight group datagradient by performing the first back computation on the n^(th) layer inthe first data type, and update the weight group data of the n^(th)layer based on the weight group data gradient.

BRIEF DESCRIPTION OF THE DRAWINGS

In order to illustrate the technical solutions in the examples of thepresent disclosure more clearly, the drawings to be used in thedescription of the examples will be briefly explained below. Obviously,the drawings in the description below are some examples of the presentdisclosure. Other drawings can be obtained according to the discloseddrawings without any creative effort by those skilled in the art.

FIG. 1a is a structural diagram of integrated circuit chip apparatus.

FIG. 1b is a structural diagram of other integrated circuit chipapparatus.

FIG. 1c is a structural diagram of a basic processing circuit.

FIG. 1d is a schematic diagram of a fixed point data type.

FIG. 1e is a structural diagram of integrated circuit chip apparatus.

FIG. 1f is a structural diagram of other integrated circuit chipapparatus.

FIG. 1g is a structural diagram of a basic processing circuit.

FIG. 1h is a structural diagram of integrated circuit chip apparatus.

FIG. 1i is a structural diagram of other integrated circuit chipapparatus.

FIG. 1j is a structural diagram of integrated circuit chip apparatus.

FIG. 1k is a structural diagram of other integrated circuit chipapparatus.

FIG. 1l is a structural diagram of integrated circuit chip apparatus.

FIG. 1m is a schematic diagram of a neural network training method.

FIG. 2a is a flow chart of a matrix-multiply-vector computation.

2 b is a schematic diagram of a matrix-multiply-vector computation.

FIG. 2c is a flow chart of a matrix-multiply-matrix computation.

FIG. 2d is a schematic diagram showing a matrix Ai being multiplied by avector B.

FIG. 2e is a schematic diagram showing a matrix A being multiplied by avector B.

FIG. 2f is a schematic diagram showing a matrix Ai being multiplied by amatrix B.

FIG. 2g is a schematic diagram showing a usage of a basic processingcircuit.

FIG. 2h is a schematic diagram showing data transferring by a mainprocessing circuit.

FIG. 2i is a structural diagram of integrated circuit chip apparatus.

FIG. 2j is a structural diagram of other integrated circuit chipapparatus.

FIG. 3a is a schematic diagram of neural network training.

FIG. 3b is a schematic diagram of a convolution computation.

FIG. 3c is a schematic diagram of convolution input data.

FIG. 3b is a schematic diagram of a convolution kernel.

FIG. 3e is a schematic diagram of a computation window of athree-dimensional data block of input data.

FIG. 3f is a schematic diagram of another computation window of athree-dimensional data block of input data.

FIG. 3g is a schematic diagram of yet another computation window of athree-dimensional data block of input data.

FIG. 4a is a schematic diagram of a forward computation of a neuralnetwork.

FIG. 4b is a schematic diagram of a back computation of a neuralnetwork.

FIG. 4c is a structural diagram of a processing apparatus according tothe disclosure.

FIG. 4d is another structural diagram of a processing apparatusaccording to the disclosure.

FIG. 4e is a method flow chart of a matrix-multiply-matrix computation.

FIG. 4f is a method flow chart of a matrix-multiply-vector computation.

FIG. 5a is a schematic diagram of another forward computation of aneural network.

FIG. 5b is a schematic diagram of another back computation of a neuralnetwork.

FIG. 5c is a structural diagram of a neural network processor board cardaccording to an example of the present disclosure.

FIG. 5d is a structural diagram of a neural network chip packagestructure according to an example of the present disclosure.

FIG. 5e is a structural diagram of a neural network chip according to anexample of the present disclosure.

FIG. 6a is a schematic diagram of a neural network chip packagestructure according to an example of the present disclosure.

FIG. 6b is a schematic diagram of another neural network chip packagestructure according to an example of the present disclosure.

FIG. 7a is another schematic diagram of neural network training.

FIG. 7b is a schematic diagram of a forward computation and a backcomputation of a neural network.

FIG. 7c is a schematic diagram of a multi-layer structure of neuralnetwork training.

DETAILED DESCRIPTION

To help those skilled in the art to understand the present disclosurebetter, the technical solutions in the examples of the presentdisclosure will be described clearly and completely hereinafter withreference to the accompanied drawings in the examples of the presentdisclosure. Obviously, the described examples are merely some ratherthan all examples of the present disclosure. All other examples obtainedby those of ordinary skill in the art based on the examples of thepresent disclosure without creative efforts shall fall within theprotection scope of the present disclosure.

FIG. 1a is a structural diagram of integrated circuit chip apparatus. Asshown in FIG. 1 a, the chip apparatus may include a main processingcircuit, a basic processing circuit, and a branch processing circuit(optional), where the main processing circuit may include a registerand/or an on-chip caching circuit. As shown in FIG. 1c , the mainprocessing circuit may further include a control circuit, a vectorcomputing unit circuit, an ALU (Arithmetic and Logic Unit) circuit, anaccumulator circuit, a DMA (Direct Memory Access) circuit, and the like.In certain applications, the main processing circuit may further includea conversion circuit (e.g., a matrix transposition circuit), a datarearrangement circuit, an activation circuit, or the like.

Alternatively, the main processing circuit may include: a data typeconversion circuit, where the data type conversion circuit may beconfigured to convert received or transferred data from floating pointdata to fixed point data. Of course, in certain applications, the datatype conversion circuit may also convert fixed point data into floatingpoint data. The present disclosure does not restrict a form of the datatype conversion circuit.

The main processing circuit may also include a data transferringcircuit, a data receiving circuit or interface, where a datadistribution circuit and a data broadcasting circuit may be integratedin the data transferring circuit. In in certain applications, the datadistribution circuit and the data broadcasting circuit may be setindependently; the data transferring circuit and the data receivingcircuit may also be integrated to form a data transceiving circuit. Datafor broadcasting refers to data that are to be sent to each basicprocessing circuit. Data for distribution refers to data that are to beselectively sent to some basic processing circuits. A selection methodmay be determined by the main processing circuit according to its loadand a computation method. A method of broadcasting refers totransferring the data for broadcasting to each basic processing circuitby means of broadcasting. In some embodiments, the data for broadcastingmay be transferred to each basic processing circuit by broadcasting foronce or a plurality of times. The times of broadcasting are notrestricted in the example of the present disclosure. A method ofdistributing refers to selectively transferring the data fordistribution to some basic processing circuits.

When distributing data, the control circuit of the main processingcircuit may transfer data to some or all of the basic processingcircuits (the data may be identical or different). Specifically, if datais transferred by means of distribution, data received by each basicprocessing circuit may be different, and of course some of the basicprocessing circuits may receive the same data. Specifically, whenbroadcasting data, the control circuit of the main processing circuitmay transfer data to some or all of the basic processing circuits, andeach basic processing circuit may receive the same data.

Alternatively, the vector computing unit circuit of the main processingcircuit may be configured to perform a vector computation which mayinclude but is not limited to: addition, subtraction, multiplication,and division between two vectors; addition, subtraction, multiplication,and division between a vector and a constant; or any computationperformed on each element in a vector. A computation performed by themain processing circuit may be addition, subtraction, multiplication,division, activation computation, accumulation computation, and thelike, between a vector and a constant.

Each basic processing circuit may include a basic register and/or abasic on-chip caching circuit. Each basic processing circuit may furtherinclude one or more of an inner product computing unit circuit, a vectorcomputing unit circuit, an accumulator circuit, and the like. The innerproduct computing unit circuit, the vector computing unit circuit, andthe accumulator circuit may all be integrated circuits, and the innerproduct computing unit, the vector computing unit circuit, and theaccumulator circuit may also be circuits that are set independently.

In an alternative example, the chip apparatus may also include one ormore branch processing circuits. If a branch processing circuit isincluded, the main processing circuit may be connected to the branchprocessing circuit, and the branch processing circuit may be connectedto the basic processing circuits. The inner product computing unit of abasic processing circuit may be configured to perform an inner productcomputation between data blocks. The control circuit of the mainprocessing circuit may control the data receiving circuit or the datatransferring circuit to receive or transfer external data, and controlthe data transferring circuit to distribute the external data to thebranch processing circuit. The branch processing circuit may beconfigured to receive data from and transfer data to the main processingcircuit or the basic processing circuit. A structure shown in FIG la maybe suitable for complex data computations, which is due to a fact that acount of units connected to the main processing circuit is limited, anda branch processing circuit may be added between the main processingcircuit and the basic processing circuits so that more basic processingcircuits can be connected, which may thereby realize computations ofcomplex data blocks. A connection structure of the branch processingcircuit and the basic processing circuits may be arbitrary and is notrestricted to an H-shape structure in FIG. 1 a. Alternatively, a datatransferring direction from the main processing circuit to the basicprocessing circuits may be a direction of broadcasting or distribution,and a data transferring direction from the basic processing circuits tothe main processing circuit may be a direction of gathering.Broadcasting, distribution, and gathering are defined as follows: adistribution or broadcasting structure refers to that a count of thebasic processing circuits is greater than a count of the main processingcircuit, in other words, one main processing circuit corresponds to aplurality of basic processing circuits, and a structure from the mainprocessing circuit to the plurality of basic processing circuits is abroadcasting or distribution structure. On the contrary, a structurefrom the plurality of basic processing circuits to the main processingcircuit may be a structure of gathering.

The basic processing circuit may be configured to receive data that aredistributed or broadcast by the main processing circuit, and store thedata in the on-chip caches of the basic processing circuit. The basicprocessing circuit may be configured to perform computations to obtainresults, and send data to the main processing circuit.

Data involved in the basic processing circuit may be data of any datatype, data represented by a floating point number of any bit width, ordata represented by a fixed point number of any bit width. Allcomputational circuits and storage circuits that are involved may becomputational circuits and storage circuits that are capable ofprocessing data of any type, computational circuits and storage circuitsfor a floating point number of any bit width, or computational circuitsand storage circuits for a fixed point number of any bit width.

Alternatively, each basic processing circuit may include a data typeconversion circuit, or some basic processing circuits may include a datatype conversion circuit. The data type conversion circuit may beconfigured to convert received or transferred data from floating pointdata to fixed point data, and may also be configured to convert fixedpoint data into floating point data. The present disclosure does notrestrict a form of the data type conversion circuit.

Alternatively, the vector computing unit circuit of the basic processingcircuit may be configured to perform a vector computation on two vectorsthat have been subject to data type conversion. Of course, in in certainapplications, the inner product computing unit circuit of the basicprocessing circuit may also be configured to perform an inner productcomputation on two vectors that have been subject to data typeconversion, and the accumulator circuit may also be configured toaccumulate results of inner product computations.

In an alternative example, two vectors may be stored in the on-chipcache and/or the register. The basic processing circuit may fetch thetwo vectors to perform a computation according to computational needs.The computation may include, but is not limited to: an inner productcomputation, a multiplication computation, an addition computation, oranother computation.

In an alternative example, a result of inner product computation may beaccumulated in the on-chip cache and/or the register. Technical effectsof this alternative example include that data that are transferredbetween the basic processing circuit and the main processing circuit maybe reduced, the computational efficiency may be improved, and the powerconsumption of data transferring may be reduced.

In an alternative example, a result of inner product computation may betransferred as a result without being accumulated. Technical effects ofthis alternative example include that the amount of computation in thebasic processing circuit may be reduced, and the computationalefficiency of the basic processing circuit may be improved.

In an alternative example, each basic processing circuit may beconfigured to perform inner product computations of a plurality groupsof two vectors, and may also be configured to accumulate results of aplurality groups of inner product computations respectively. In analternative example, data of the plurality groups of two vectors may bestored in the on-chip cache and/or the register. In an alternativeexample, the results of a plurality groups of inner product computationsmay be accumulated in the on-chip cache and/or the registerrespectively. In an alternative example, each result of a pluralitygroups of inner product computations may be transferred as a resultwithout being accumulated. In another alternative example, each basicprocessing circuit may be configured to perform inner productcomputations between a same vector and a plurality of vectorsrespectively (one-to-many inner product, which in other words, refers tothat for a plurality groups of vectors, one vector in the two vectors ofeach group is shared), and accumulate an inner product corresponding toeach vector respectively. By using the technical solution, a same set ofweights can be used for performing a plurality of computations ondifferent input data, which may increase data reusing, reduce internaldata transferring of the basic processing circuit, improve computationalefficiency, and reduce power consumption.

Specifically, regarding data used for computing inner products, a datasource of a shared vector and a data source of the other vector (thedifferent vector in each group) of each group may be different: in analternative example, when computing inner products, the shared vector ofeach group may be broadcast or distributed from the main processingcircuit or the branch processing circuit. In an alternative example,when computing inner products, the shared vector of each group may befrom the on-chip cache. In an alternative example, when computing innerproducts, the shared vector of each group may be from the register. Inanother alternative example, when computing inner products, thenon-shared vector of each group may be broadcast or distributed from themain processing circuit or the branch processing circuit. In analternative example, when computing inner products, the non-sharedvector of each group may be from the on-chip cache. In an alternativeexample, when computing inner products, the non-shared vector of eachgroup may be from the register. In an alternative example, whencomputing a plurality groups of inner products, the shared vector ofeach group may be saved in any count of copies in the on-chip cacheand/or the register of the basic processing circuit. In an alternativeexample, for each groups of inner products, one copy of the sharedvector may be saved correspondingly. In an alternative example, theshared vector may be saved as one copy only. Specifically, results of aplurality groups of inner product computations may be accumulated in theon-chip cache and/or the register respectively. Specifically, eachresult of the plurality groups of inner product computations may betransferred as a result without being accumulated. Referring to astructure shown in FIG. 1a , the structure includes a main processingcircuit (capable of performing vector operation) and a plurality ofbasic processing circuits (capable of performing inner productoperation). A technical effect of the combination is that the apparatuscan not only use the basic processing circuits to perform matrix andvector multiplication, but can also use the main processing circuit toperform any other vector computations, so that the apparatus maycomplete more computations faster with a configuration where a limitedcount of hardware circuits are included. The combination may reduce acount of times that data is transferred with the external of theapparatus, improve computational efficiency, and reduce powerconsumption. Besides, in the chip, a data type conversion circuit may bearranged in the basic processing circuit and/or the main processingcircuit, so that floating point data may be converted into fixed pointdata when a neural network computation is being performed, and fixedpoint data may also be converted into floating point data. In addition,the chip may also dynamically allocate a circuit to perform data typeconversion according to the amount of computation (loads) of eachcircuit (mainly the main processing circuit and the basic processingcircuit), which may reduce complex procedures of data computation andreduce power consumption. By dynamically allocating a circuit to performdata type conversion, the computational efficiency of the chip may notbe affected. An allocation method may include but is not limited to:load balancing, load minimum allocation, and the like.

FIG. 1d is a structural diagram of the fixed point data. FIG. 1d shows amethod of representing fixed point data. For a computing system, thestorage bit of one floating point data is 32 bits. For fixed point data,particularly a data representation using the floating point data shownin FIG. 1d , the storage bit of one fixed point data can he reduced toless than 16 bits, which may greatly reduce transferring overheadbetween computing units during conversion. In addition, for a computingunit, the storage space of data having fewer bits may be smaller, inother words, the storage overhead may be less, the amount ofcomputations may also be reduced, and the computational overhead may bereduced. In this case, the fixed point data shown in FIG. 1d may reducethe computational overhead and storage overhead. However, data typeconversion requires computational overhead, which will be referred to asconversion overhead below. For data that require a large amount ofcomputations and a large amount of storage, conversion overhead isalmost negligible compared with subsequent computational overhead,storage overhead, and transferring overhead. In this case, the presentdisclosure adopts a technical solution of converting data into fixedpoint data for data that require a large amount of computations and alarge amount of storage. On the contrary, for data that require a smallamount of computations and a small amount of storage, the data requireless computational overhead, storage overhead, and transferringoverhead. Since the precision of fixed point data is lower than theprecision of floating point data, if fixed point data is used, under thepremise that an amount of computations is relatively small, the fixedpoint data may be converted to floating point data to ensure theprecision of computations. In other words, the precision of computationsmay be improved by increasing a small amount of overhead.

Referring to the apparatus shown in FIG. 1b , the apparatus does notinclude any branch processing circuit. The apparatus in FIG. 1 b mayinclude a main processing circuit and N basic processing circuits, wherethe main processing circuit (whose structure is shown in FIG. 1c ) maybe connected to the N basic processing circuits directly or indirectly.If the main processing circuit is connected to the N basic processingcircuits indirectly, an alternative connection scheme is shown in FIG.1a , where N/4 branch processing circuits may be included, and eachbranch processing circuit may be connected to four basic processingcircuits respectively. Regarding circuits that are included in the mainprocessing circuit and the N basic processing circuits, a description ofthem can be seen in the description of FIG. 1a , which is omitted here.It should be explained that the basic processing circuits may also bearranged inside the branch processing circuits, and besides, a count ofbasic processing circuits that are connected to each branch processingcircuit may not be restricted to 4. Manufacturers can set the countaccording to actual needs. The main processing circuit and/or the Nbasic processing circuits may all include a data type conversioncircuit. Specifically, it may be the main processing circuit thatincludes a data type conversion circuit, and may also be the N basicprocessing circuits or some of the basic processing circuits thatinclude a data type conversion circuit, and may further be the mainprocessing circuit, and the N basic processing circuits or some of thebasic processing circuits that include a data type conversion circuit.

The main processing circuit may dynamically allocate an entity toperform a step of data type conversion according to a neural networkcomputation instruction. Specifically, the main processing circuit maydetermine whether to perform the step of data type conversion onreceived data according to its loads. Specifically, a value of the loadsmay be set as a plurality of ranges, where each range corresponds to anentity that performs the step of data type conversion. Taking threeranges as an instance: range 1 corresponds to light loads, where themain processing circuit may perform the step of data type conversionalone; range 2 corresponds to loads between range 1 and range 3, wherethe main processing circuit or the N basic processing circuits mayperform the step of data type conversion together; and range 3corresponds to heavy loads, where the N basic processing circuits mayperform the step of data type conversion. Data type conversion may beperformed explicitly. For instance, the main processing circuit canconfigure a special indication or instruction, when the basic processingcircuits receive the special indication or instruction, the basicprocessing circuits determine to perform the step of data typeconversion, and when the basic processing circuits do not receive thespecial indication or instruction, the basic processing circuitsdetermine not to perform the step of data type conversion. Data typeconversion may also be performed implicitly. For instance, when thebasic processing circuits receive data of a floating point type anddetermine that an inner product computation needs to be performed, thebasic processing circuits convert the type of the data into a fixedpoint type.

A method for realizing computations by using the apparatus shown in FIG.1a is provided below. The method of computation may be a computationmethod of neural networks. For instance, a forward computation of aneural network and training of a neural network. In in certainapplications, according to different input data, a forward computationmay perform computations such as a matrix-multiply-matrix computation, aconvolution computation, an activation computation, a transformationcomputation. All of the above-mentioned computations may be performed byusing the apparatus of FIG. 1 a.

A data type conversion circuit of the main processing circuit may firstconvert the type of data, then the control circuit may transfer the datato the basic processing circuits for computing. For instance, the datatype conversion circuit of the main processing circuit may convert afloating point number to a fixed point number that has less bit widthand transfer the fixed point number to the basic processing circuits.Technical effects of this method include that the bit width of datatransferred may be reduced, the total count of bits being transferredmay be reduced, the basic processing circuits may achieve betterefficiency with less power consumption When perform bit width fixedpoint computations.

If data received by the basic processing circuits receive are floatingpoint data, after the basic processing circuits receive the data, thedata type conversion circuit may first perform data type conversion,then the basic processing circuits may perform computations. Forinstance, the basic processing circuits receive a floating point numbertransferred from the main processing circuit, the data type conversioncircuit converts the floating point number to a fixed point number, thenthe inner product computing unit circuit, the vector computing unitcircuit, or the accumulator circuit of the basic processing circuitsperform computations. In this way, the computational efficiency may beimproved, and the power consumption may be reduced.

After the basic processing circuits obtain results by computing, theresults may first be subject to data type conversion and then betransferred to the main processing circuit. For instance, a computationresult which is a floating point number that is obtained by the basicprocessing circuits is first converted into a fixed point number havinga less bit width, then the fixed point number is transferred to the mainprocessing circuit. Technical effects of this method include that thebit width during the transferring process may be reduced, and betterefficiency with less power consumption may be realized.

The main processing circuit may transfer data that are to be computed toall or some of the basic processing circuits. Taking amatrix-multiply-vector computation as an instance, the control circuitof the main processing circuit may partition matrix data to obtain eachcolumn of the data and each row of the data for serving as basic data.For instance, a m*n matrix can be partitioned into n vectors each with mrows, and the control circuit of the main processing circuit maydistribute the n vectors with m rows obtained by partitioning to theplurality of basic processing circuits. For a vector, the controlcircuit of the main processing circuit may broadcast the whole vector toeach of the basic processing circuits. If the value of m is relativelylarge, the control circuit may first partition an m*n matrix into x*nvectors. Taking x=2 as an instance, specifically, the matrix may bepartitioned into 2n vectors, where each vector includes m/2 rows. Inother words, each vector of n vectors with m rows is divided into 2vectors evenly. Taking a first row as an instance, if a first vector ofthe n vectors with m rows has 1000 rows, a way to partition the firstvector into 2 vectors evenly may be making previous 500 rows as a firstvector and subsequent 500 rows as a second vector, then the controlcircuit may broadcast the two vectors for twice to the plurality ofbasic processing circuits.

A method for the data transferring may be broadcasting or distributing,or any other possible transferring method. After receiving data, thebasic processing circuits may perform computations to obtain computationresults. The basic processing circuits may transfer the computationresults to the main processing circuit. The computation results may beintermediate computation results, and may also be final computationresults.

The present disclosure further provides a computation of amatrix-multiply vector that is performed by using the apparatus of FIG.1 a. (the matrix-multiply vector may be a vector obtained by: performinginner product computations between each row of a matrix and a vector,and placing the obtained results according to a corresponding order.)

Below is the description of performing multiplication of a matrix S witha size of M rows and L columns and a vector P with a length of L, whichis shown in FIG. 2b (each row of the matrix S is as long as the vectorP, and data of them are in one-to-one correspondence according topositions), the neural network computing apparatus has K basicprocessing circuits: referring to FIG. 2a , an implementation method ofmatrix-multiply-vector is provided, which may include: S201, converting,by the data type conversion circuit of the main processing circuit, dataof each row in the matrix S into fixed point data; distributing, by thecontrol circuit of the main processing circuit, the fixed point data toone of the K basic processing circuits; and storing, by the basicprocessing circuit, the received data in the on-chip cache and/orregister of the basic processing circuit.

As an alternative example, M is the count of rows of the matrix S, ifM<=K, the control circuit of the main processing circuit may distributea row of the matrix S to the K basic processing circuits respectively.As an alternative example, M is the count of rows of the matrix S, ifM>K, the control circuit of the main processing circuit may distributedata of one or a plurality of rows of the matrix S to each basicprocessing circuits respectively.

For instance, a set of rows of the matrix S that are distributed to ani^(th) basic processing circuit may be referred to as Ai, which has Mirows in total. FIG. 2d shows a computation to be performed by the i^(th)basic processing circuit.

As an alternative example, for each basic processing circuit, such as inthe i^(th) basic processing circuit, the received data such as a matrixAi which is transferred by means of distributing may be stored in theregister and/or on-chip cache. Technical effects of the example includethat data that are transferred during subsequent data distribution maybe reduced, the computational efficiency may be improved, and the powerconsumption may be reduced.

The method may further include: 5202, converting, by the data typeconversion circuit of the main processing circuit, the vector P intofixed point data, and transferring by means of broadcasting, by thecontrol circuit of the main processing circuit, each part of the vectorP having a fixed point type to the K basic processing circuits.

As an alternative example, the control circuit of the main processingcircuit may broadcast each part of the vector P for only once to theregister or on-chip cache of each basic processing circuit, the i^(th)basic processing circuit may fully reuse data of the vector P which isobtained at this time to complete an inner product computationcorresponding to each row of the matrix Ai. Technical effects of theexample include that the data of the vector P which are repeatedlytransferred from the main processing circuit to the basic processingcircuits may be reduced, the execution efficiency may be improved, andthe power consumption for transferring may be reduced.

As an alternative example, the control circuit of the main processingcircuit may sequentially broadcast each part of the vector P to theregister or on-chip cache of each basic processing circuit, the i^(th)basic processing circuit may not reuse data of the vector P which isobtained at each time, and may complete an inner product computationcorresponding to each row of the matrix Ai at different times. Technicaleffects of the example include that the data of the vector P which istransferred at a single time in the basic processing circuits may bereduced, the capacity of the cache and/or register of the basicprocessing circuits may be reduced, the execution efficiency may beimproved, the power consumption of transferring may be reduced, and thecosts may be reduced.

As an alternative example, the control circuit of the main processingcircuit may sequentially broadcast each part of the vector P to theregister or on-chip cache of each basic processing circuit, the i^(th)basic processing circuit may partly reuse data of the vector P which isobtained at each time to complete an inner product computationcorresponding to each row of the matrix Ai. Technical effects of theexample include that data that are transferred from the main processingcircuit to the basic processing circuit may be reduced, data that aretransferred within the basic processing circuits may be reduced, theexecution efficiency may be improved, and the power consumption oftransferring may be reduced.

The method may further include: 5203, computing, by the inner productcomputing unit circuit of the K basic processing circuits, an innerproduct of the matrix S and the vector P, for instance, computing, bythe i^(th) basic processing circuit, an inner product of the data ofmatrix Ai and the data of the vector P; and 5204, accumulating, by theaccumulator circuit of the K basic processing circuits, a result of theinner product computation to obtain an accumulation result, andtransferring the accumulation result in a fixed point type to the mainprocessing circuit.

As an alternative example, a partial sum obtained from the inner productcomputation performed each time by the basic processing circuits may betransferred to the main processing circuit for accumulating (the partialsum refers to part of the accumulation result, for instance, if theaccumulation result is F1*G1+F2*G2+F3*G3+F4*G4+F5*G5, the partial summay be the value of F1*G1+F2*G2+F3*G3). Technical effects of the exampleinclude that computations performed within the basic processing circuitsmay be reduced, and the computational efficiency of the basic processingcircuits may be improved.

In an alternative example, a partial sum obtained from the inner productcomputation performed each time by the basic processing circuits may bestored in the on-chip cache and/or the register of the basic processingcircuits, and transferred to the main processing circuit after theaccumulation ends. Technical effects of the example include that datawhich are transferred between the basic processing circuits and the mainprocessing circuit may be reduced, the computational efficiency may beimproved, and the power consumption of data transferring may be reduced.

As an alternative example, a partial sum obtained from the inner productcomputation performed each time by the basic processing circuits mayalso, in some cases, be stored in the on-chip caching circuit and/or theregister of the basic processing circuits for accumulating, and in somecases, be transferred to the main processing circuit for accumulating,then be transferred to the main processing circuit after theaccumulation ends. Technical effects of the example include that datawhich are transferred between the basic processing circuits and the mainprocessing circuit may be reduced, the computational efficiency may beimproved, the power consumption of data transferring may be reduced,computations performed within the basic processing circuits may bereduced, and the computational efficiency of the basic processingcircuits may be improved.

FIG. 2c is a flow chart of using the apparatus of FIG. 1a to perform amatrix-multiply-matrix computation.

Below is a description of performing multiplication of a matrix S with asize of M rows and L columns and a matrix P with a size of I, rows and Ncolumns (each row of the matrix S is as long as each column of thematrix P, which is as shown in FIG. 2e ), and the neural networkcomputing apparatus has K basic processing circuits: the method mayfurther include: S201 b, distributing, by the control circuit of themain processing circuit, data of each row in the matrix S to one of theK basic processing circuits; and storing, by the basic processingcircuit, the received data in the on-chip cache and/or register. As analternative example, M is the count of rows of the matrix S, if M<=K,the control circuit of the main processing circuit may distribute a rowof the matrix S to M basic processing circuits respectively. As analternative example, M is the count of rows of the matrix S, if M>K, thecontrol circuit of the main processing circuit may distribute data ofone or a plurality of rows of the matrix S to each basic processingcircuits respectively.

In a case where Mi rows of the matrix S are distributed to an i^(th)basic processing circuit, a set of the Mi rows can be referred to as Ai.FIG. 2f shows a computation to be performed by the i^(th) basicprocessing circuit.

As an alternative example, in each of the basic processing circuits, forinstance, in the i^(th) basic processing circuit: the matrix Aidistributed by the main processing circuit may be received and stored inthe register and/or on-chip cache of the i^(th) basic processingcircuit. Technical effects of the example include that data that aretransferred afterwards may be reduced, the computational efficiency maybe improved, and the power consumption may be reduced.

The method may further include: S202 b, transferring by means ofbroadcasting, by the control circuit of the main processing circuit,each part of the matrix P to each basic processing circuits.

As an alternative example, each part of the matrix P may be broadcastfor only once to the register or on-chip cache of each basic processingcircuit, the i^(th) basic processing circuit may fully reuse data of thematrix P which is obtained at this time to complete an inner productcomputation corresponding to each row of the matrix Ai. The reusingmentioned in the example may be repeatedly using data by the basicprocessing circuits during computation, for instance, reusing data ofthe matrix P may be using the data of the matrix P for a plurality oftimes.

As an alternative example, the control circuit of the main processingcircuit may sequentially broadcast each part of the matrix P to theregister or on-chip cache of each basic processing circuit, the i^(th)basic processing circuit may not reuse the data of the matrix P which isobtained at each time, and may complete an inner product computationcorresponding to each row of the matrix Ai at different times.

As an alternative example, the control circuit of the main processingcircuit may sequentially broadcast each part of the matrix P to theregister or on-chip cache of each basic processing circuit, the i^(th)basic processing circuit may partially reuse the data of the matrix Pwhich is obtained at each time to complete an inner product computationcorresponding to each row of the matrix Ai. In an alternative example,each of the basic processing circuits, for instance, the i^(th) basicprocessing circuit, may compute an inner product of the data of thematrix Ai and the data of the matrix P.

The method may include Step S203 b: accumulating, by the accumulatorcircuit of each of the basic processing circuits, a result of the innerproduct computation, and transferring an accumulation result to the mainprocessing circuit.

As an alternative example, the basic processing circuits may transfer apartial sum obtained from each inner product computation to the mainprocessing circuit for accumulating. In an alternative example, apartial sum obtained from the inner product computation performed eachtime by the basic processing circuits may be stored in the on-chipcaching circuit and/or the register of the basic processing circuits,and transferred to the main processing circuit after the accumulationends. As an alternative example, a partial sum obtained from the innerproduct computation performed each time by the basic processing circuitsmay also, in some cases, be stored in the on-chip caching circuit and/orthe register of the basic processing circuits for accumulating, and insome cases, be transferred to the main processing circuit foraccumulating, then be transferred to the main processing circuit afterthe accumulation ends.

FIG. 3a shows a fully connected computation performed by using theapparatus of FIG. 1a : if input data of a fully connected layer is avector (in other words, a case when input of a neural network is asingle sample), a weight matrix of the fully connected layer serves asthe matrix S, an input vector serves as the vector P, amatrix-multiply-vector computation as shown in FIG. 2a may be performedby following the method one of the apparatus.

If the input data of the fully connected layer is a matrix (in otherwords, a case when the input of the neural network is a plurality ofsamples serving as a batch), the weight matrix of the fully connectedlayer serves as the matrix S, the input vector serves as the matrix P orthe weight matrix of the fully connected layer serves as the matrix P,and the input vector serves as the matrix S. A matrix-multiply-matrixcomputation as shown in FIG. 2d may be performed by following the methodof the apparatus.

FIG. 3b is a flow chart of using the apparatus of FIG. 1a to perform aconvolution computation: for a convolutional layer, let a count ofconvolution kernels of the layer be M; the method may further includeS301: distributing, by the control circuit of the main processingcircuit, a weight of each convolution kernel in a weight of theconvolutional layer to one of the K basic processing circuits, andstoring it in the on-chip cache and/or register of the basic processingcircuits. As an alternative example, if the count of the convolutionkernels M>=K, the control circuit of the main processing circuit maydistribute a weight of a convolution kernel to M basic processingcircuits respectively. As an alternative example, if the count of theconvolution kernels M>K, the control circuit of the main processingcircuit may distribute weights of one or a plurality of convolutionkernels to each basic processing circuits respectively.

Mi convolution kernels are distributed to an i^(th) basic processingcircuit in total, and a set of the Mi convolution kernels is referred toas Ai.

As an alternative example, in each of the basic processing circuits, forinstance, in the i^(th) basic processing circuit: storing theconvolution kernel weights Ai distributed by the main processing circuitin the register and/or on-chip cache.

The method may further include: S302, transferring by means ofbroadcasting, by the control circuit of the main processing circuit,each part of the input data P to each basic processing circuit. As analternative example, the control circuit of the main processing circuitmay broadcast each part of the input data P for only once to theregister or on-chip cache of each basic processing circuit, the i^(th)basic processing circuit may fully reuse data of the input data P whichis obtained at this time to complete an inner product computationcorresponding to each convolution kernel of the Ai. As an alternativeexample, the control circuit of the main processing circuit maysequentially broadcast each part of the input data P to the register oron-chip cache of each basic processing circuit, the i^(th) basicprocessing circuit may not reuse the data of the input data P which isobtained at each time, and may complete an inner product computationcorresponding to each convolution kernel of the Ai at different times.As an alternative example, the control circuit of the main processingcircuit may sequentially broadcast each part of the input data P to theregister or on-chip cache of each basic processing circuit, the i^(th)basic processing circuit may partially reuse the data of the input dataP which is obtained at each time to complete an inner productcomputation corresponding to each convolution kernel of the Ai.

The method may further include: S303, computing, by each basicprocessing circuit, an inner product of a convolution kernel and theinput data P, for instance, computing, by the i^(th) basic processingcircuit, an inner product of each convolution kernel of the Ai and thedata of the input data P; S304: accumulating, by the accumulator circuitof each basic processing circuit, a result of the inner productcomputation, and transferring an accumulation result to the mainprocessing circuit. As an alternative example, the basic processingcircuits may transfer a partial sum obtained from each inner productcomputation to the main processing circuit for accumulating. In analternative example, the basic processing circuits may store a partialsum obtained from the inner product computation performed each time inthe on-chip cache and/or register of the basic processing circuits, andtransfer to the main processing circuit after the accumulation ends. Asan alternative example, in some cases, the basic processing circuits mayalso store a partial sum obtained from the inner product computationperformed each time in the on-chip cache and/or the register of thebasic processing circuits for accumulating, and in some cases, transferto the main processing circuit for accumulating, and then transfer tothe main processing circuit after the accumulation ends.

Alternatively, the present disclosure further provides a method of usingthe apparatus shown in FIG. 1a to update a weight, including: using thevector computing unit circuit of the main processing circuit to realizea function of weight updating during neural network training,specifically, the weight updating refers to a method of using a gradientof the weight to update the weight.

In an alternative example, the vector computing unit circuit of the mainprocessing circuit may be used to perform addition and subtractioncomputations on the weight and the gradient of the weight, which are twovectors, to obtain a computation result, and the computation result isan updated weight.

In an alternative example, the vector computing unit circuit of the mainprocessing circuit may be used to perform addition and subtractioncomputations on the weight and the gradient of the weight, which are twovectors, to obtain a computation result, and the computation result isan updated weight.

In an alternative example, the gradient of the weight may first be usedfor computing to obtain a group of momentum, then the momentum and theweight may be used to perform addition and subtraction computations toobtain an updated weight; alternatively, the present disclosure mayfurther include a method of using the apparatus shown in FIG. 1 a torealize a back computation of a fully connected layer: the backcomputation of the fully connected layer may be divided into two parts,as shown in FIG. 4a , an arrow with continuous line represents a processof a forward computation of the fully connected layer, and FIG. 4b showsa process of back computation of the fully connected layer.

The back computations of the fully connected layer as shown in FIG. 4aand FIG. 4h may he performed by using the apparatus of FIG. 1a and thematrix-multiply-matrix method of FIG. 2 c.

Alternatively, the present disclosure may further include using theapparatus of FIG. 1a to perform a back operation of a convolutionallayer. The back computation of the convolutional layer may be dividedinto two parts, as shown in FIG. 5a , an arrow with continuous linerepresents a process of a forward computation of the convolutionallayer, and FIG. 5b shows a process of the back computation of theconvolutional layer.

The back computations of the convolutional layers as shown in FIG. 5aand FIG. 5h may be performed by using the apparatus of FIG. 1a and themethod of FIG. 3 b.

Alternatively, the present disclosure may further include a method ofusing the apparatus shown in FIG. 1a to realize a BLAS (Basic LinearAlgebra Subprograms) function:

A GEMM computation refers to a computation of matrix-matrixmultiplication in a BLAS library. A common representation of thecomputation is C=alpha*op(S)*op(P)+beta*C, where S and P are two inputmatrices, C is an output matrix, alpha and beta are scalars, oprepresents an operation performed on the matrix S or P, in addition,other supporting integers may be used as parameters to explain the widthand height of the matrices S and P; alternatively, the presentdisclosure may further include a step of using the apparatus shown inFIG. 1a to realize the GENIM computation, including: performing, by thedata. type conversion circuit of the main processing circuit, data typeconversion on the matrix S and the matrix P; performing, by theconversion circuit of the main processing circuit, corresponding opoperation on the matrix S and the matrix P respectively; as analternative example, op may be a matrix transposition operation; thematrix transposition circuit of the main processing circuit may be usedto realize the matrix transposition operation. In an alternativeexample, after the op operation of the matrix S and the matrix P isperformed, the data type conversion circuit of the main processingcircuit may perform data type conversion operation. In other words, thedata type conversion circuit may convert the data types of op(S) andop(P) from floating point data into fixed point data, then perform amatrix multiplication computation as shown in FIG. 2 c.

As an alternative example, op of a matrix may be null, and the opoperation may not be performed. The apparatus of FIG. 1a and thematrix-multiply-matrix computation method of FIG. 2c may be used toperform a matrix multiplication computation between op(S) and op(P); thearithmetic and logic unit of the main processing circuit may be used toperform an operation of multiplying each value in a result ofop(S)*op(P) by alpha. As an alternative example, in case when alpha is1, the operation of multiplying by alpha may not be performed; thearithmetic and logic unit of the main processing circuit may be used torealize a computation of beta*C. As an alternative example, in case whenbeta is I, the operation of multiplying by beta may not be performed.The vector computing unit circuit of the main processing circuit may beused to realize a step of adding corresponding positions of matricesalpha*op(S)*op(P) and beta*C to obtain a result of a GEMM computation.

As an alternative example, in case when beta is 0, the operation may notbe performed. A GEMV computation refers to a computation ofmatrix-vector multiplication in a BLAS library. A common representationof the computation is C=alpha*op(S)*P+beta*C, where S is an inputmatrix, P is an input vector, C is an output vector, alpha and beta arescalars, and op represents an operation performed on the matrix S.Alternatively, the present disclosure may further include a step ofusing the apparatus shown in FIG. 1a to realize the GEMV computation,including: performing, by the data type conversion circuit of the mainprocessing circuit, data type conversion on the input matrix S and theinput matrix P; performing, by the conversion circuit of the mainprocessing circuit, a corresponding op operation on the input matrix S.In an alternative example, op may be a matrix transposition operation,and the conversion circuit of the main processing circuit may be used torealize the matrix transposition operation. In an alternative example,when op of a matrix can be null, the transposition operation of thematrix may not be performed.

Furthermore, the apparatus of FIG. 1a and the matrix-multiply-vectorcomputation method of FIG. 2b may be used to perform a matrix-vectormultiplication computation between the matrix op(S) and the vector P.Specifically, the arithmetic and logic unit of the main processingcircuit may be used to perform an operation of multiplying each value ina result of op(S)*P by alpha. In an alternative example, when alpha is1, the operation of multiplying by alpha may not be performed; thearithmetic and logic unit of the main processing circuit may be used toperform a computation of beta*C. As an alternative example, in case whenbeta is 1, the operation of multiplying by beta may not be performed;and the vector computing unit circuit of the main processing circuit maybe used to realize a step of adding corresponding positions of matricesalpha*op(S)*P and beta*C to obtain a result of GEMV. As an alternativeexample, in case when beta is 0, the operation of adding may not beperformed.

Alternatively, the present disclosure may further include a method ofusing the apparatus shown in FIG. 1a to realize an activation function,where the method may include: inputting a vector by using the activationcircuit of the main processing circuit, and obtaining an activationvector of the vector by computing. In an alternative example, theactivation circuit of the main processing circuit may obtain a numericalvalue for each value of an input vector through an activation function(input of the activation function is a numerical value, and output isalso a numerical value) by computing, and output the numerical value toa corresponding position of an output vector. In an alternative example,the activation function may be: y=max(m, x), where x is an inputnumerical value, y is an output numerical value, and m is a constant. Inan alternative example, the activation function may be: y=tan h(x),where x is an input numerical value, and y is an output numerical value.In an alternative example, the activation function may be: y=sigmoid(x),where x is an input numerical value, y is an output numerical value. Inan alternative example, the activation function may be a piecewiselinear function; and in an alternative example, the activation functionmay be a function of randomly inputting a number and outputting anumber.

In an alternative example, a source of the input vector may include (butis not limited to): an external data source of the apparatus. In analternative example, the input data may be from a computation result ofmatrix-multiply-vector performed by the apparatus. In an alternativeexample, the input data may be from a computation result ofmatrix-multiply-matrix performed by the apparatus, or a computationresult of the main processing circuit of the apparatus; and in analternative example, the input data may be from a computation resultobtained after the main processing circuit of the apparatus is biased.

It should be explained that the activation operation may be realized bythe arithmetic and logic unit and the accumulator circuit of the mainprocessing circuit, and may also be realized by adding an activationcircuit separately to the main processing circuit.

Alternatively, the present disclosure may further use the apparatusshown in FIG. 1a to realize a computation of giving a bias: the vectorcomputing unit circuit of the main processing circuit may be used torealize a function of adding two vectors together or adding two matricestogether. The vector computing unit circuit of the main processingcircuit may be used to realize a function of adding a vector to each rowof a matrix, or to each column of a matrix.

In an alternative example, the matrix may be from a result of amatrix-multiply-matrix computation performed by the apparatus.

In an alternative example, the matrix may be from a result of amatrix-multiply-vector computation performed by the apparatus.

In an alternative example, the matrix may be from data received from theexternal by the main processing circuit of the apparatus.

In an alternative example, the vector may be from data received from theexternal by the main processing circuit of the apparatus.

In the example of the present disclosure, data sources of the matrixand/or the vector ay include but is not limited to the above-mentioneddata sources.

Alternatively, the present disclosure may further use the apparatusshown in FIG. 1a to realize data type conversion: specifically, the datatype conversion circuit of the main processing circuit may be used torealize data type conversion.

In an alternative example, the data type conversion circuit of the mainprocessing circuit may be used to realize data type conversion of agroup of data. In an alternative example, a form of data type conversionmay include but is not limited to: converting a floating point number toa fixed point number, converting a fixed point number to a floatingpoint number, and the like.

The present disclosure further provides a chip. The chip may include acomputing apparatus, where the computing apparatus may include a mainprocessing circuit and a plurality of basic processing circuits.

Data involved in the main processing circuit may be data of any datatype. In an alternative example, it may be data represented by afloating point number of any bit width, or data represented by a fixedpoint number of any bit width. All computational circuits and storagecircuits that are involved may be computational circuits and storagecircuits that are capable of processing data of any type. In analternative example, they may be computational circuits and storagecircuits for a floating point number of any bit width, or computationalcircuits and storage circuits for a fixed point number of any bit width.

In an alternative example, the main processing circuit may include adata type conversion circuit.

In an alternative example, the main processing circuit may include avector computing unit. Further, the main processing circuit may furtherinclude a data input interface that is configured to receive input data.

In an alternative example, a source of the received data may be: theexternal of the neural network computational circuit apparatus, or someor all of the basic processing circuits of the neural networkcomputational circuit apparatus.

In an alternative example, the data input interface may be plural.Specifically, the main processing circuit may further include a dataoutput interface of output data.

In an alternative example, the output data may be transferred to: theexternal of the neural network computational circuit apparatus, or someor all of the basic processing circuits of the neural networkcomputational circuit apparatus.

In an alternative example, the data output interface may be plural.

In an alternative example, the main processing circuit may include anon-chip cache and/or register.

In an alternative example, the main processing circuit may include acomputing unit that is configured to perform data computations.

In an alternative example, the main processing circuit may include anarithmetic computing unit.

In an alternative example, the main processing circuit may include avector computing unit that can perform computations on a group of datasimultaneously. Specifically, the arithmetic computation and/or vectorcomputation may be computations of any type which may include but is notlimited to: addition, subtraction, multiplication, and division betweentwo numbers; addition, subtraction, multiplication, and division betweena number and a constant; exponential computations, power computations,logarithm computations, and various nonlinear computations performed ona number; comparison computations and logical computations performed ontwo numbers; and the like. The arithmetic computation and/or vectorcomputation may further be: addition, subtraction, multiplication, anddivision between two vectors; addition, subtraction, multiplication, anddivision between each element in a vector and a constant; exponentialcomputations, power computations, logarithm computations, and variousnonlinear computations performed on each element in a vector; comparisoncomputations and logical computations performed on every twocorresponding elements in a vector, and the like.

In an alternative example, the main processing circuit may include adata rearrangement unit that is configured to transfer data to the basicprocessing circuits by following a certain order, or rearrange data insitu by following a certain order.

In an alternative example, the order for data arrangement may include:changing the order of dimensions of a multidimensional data block; andthe order for data arrangement may further include: partitioning a datablock so as to send to different basic processing circuits.

The computing apparatus may further include a plurality of basicprocessing circuits, where each basic processing circuit may beconfigured to obtain an inner product of two vectors by computing, and amethod of computing may be: receiving, by a basic processing circuit,two groups of numbers, multiplying elements in the two groups of numberscorrespondingly, and accumulating the results of multiplication; andoutputting the result of the inner product, where the result may beoutput according to the position of the basic processing circuit, may betransferred to another basic processing circuit, and may also betransferred directly to the main processing circuit.

Data involved in the basic processing circuits may be data of any datatype. In an alternative example, it may be data represented by afloating point number of any bit width, or data represented by a fixedpoint number of any bit width. All computational circuits and storagecircuits that are involved may be computational circuits and storagecircuits that are capable of processing data of any type. In analternative example, they may be computational circuits and storagecircuits for a floating point number of any bit width, or computationalcircuits and storage circuits for a fixed point number of any bit width.

In an alternative example, a basic processing circuit may include a datatype conversion circuit.

In an alternative example, a basic processing circuit may include avector computing unit that is configured to perform data typeconversion. Further, a basic processing circuit may further include astorage unit composed of an on-chip cache and/or register. Stillfurther, a basic processing circuit may further include one or more datainput interfaces that are configured to receive data.

In an alternative example, a basic processing circuit may include twodata input interfaces, and one or a plurality of data may be obtainedrespectively from the two data input interfaces at each time. In analternative example, a basic processing circuit may receive input datafrom the data input interfaces, and store the input data in the registerand/or on-chip cache; and a source of data received by the data inputinterfaces may be: other basic processing circuits and/or the mainprocessing circuit.

The main processing circuit of the neural network computingcomputational circuit apparatus, the other basic processing circuits ofthe neural network computational circuit apparatus (the neural networkcomputational circuit apparatus may have a plurality of basic processingcircuits) may be a neural network computational circuit apparatusincluding one or a plurality of data output interfaces that areconfigured to transfer output data.

In an alternative example, the neural network computational circuitapparatus may transfer one or a plurality of data via the data outputinterface. Specifically, data transferred via the data output interfacemay be one or more of: data received from the data input interface, datastored in the on-chip cache and/or register, a computation result ofmultiplier, a computation result of accumulator, or a computation resultof inner product computing unit.

In an alternative example, the neural network computational circuitapparatus may include three data output interfaces, where two dataoutput interfaces may correspond to the two data input interfaces, and athird data output interface may be configured to output computationresults. Specifically, the above-mentioned data sources and where datamay be transferred may determine a connection of the basic processingcircuits in the neural network computational circuit apparatus.

Alternatively, the main processing circuit of the neural networkcomputing computational circuit apparatus, the other basic processingcircuits of the neural network computational circuit apparatus (theneural network computational circuit apparatus may have a plurality ofbasic processing circuits) may include an arithmetic computationalcircuit, where the arithmetic computational circuit may be one or moreof: one or a plurality of multiplier circuits, one or a plurality ofaccumulator circuits, and one or a plurality of circuits that areconfigured to perform inner product computations of two groups ofnumbers.

In an alternative example, the multiplier circuit may be configured toperform multiplication of two numbers, a result of the multiplicationmay be stored in the on-chip cache and/or register, and may also beaccumulated in the register and/or the on-chip cache.

In an alternative example, the arithmetic computational circuit may beconfigured to perform inner product computations of two groups of data,a result of the computations may be stored in the on-chip cache and/orregister, and may also be accumulated in the register and/or the on-chipcache. In an alternative example, the accumulator circuit may beconfigured to perform accumulation computations of data, and the datamay also he accumulated in the register and/or the on-chip cache.Specifically, data accumulated in the accumulator circuit may be one ormore of: data received from the data input interface, data stored in theon-chip cache and/or register, a computation result of multiplier, acomputation result of accumulator, or a computation result of innerproduct computing unit.

It should be explained that the “data input interface” and “data outputinterface” used in the description of the basic processing circuitsrefer to a data input interface and a data output interface of eachbasic processing circuit, rather than a data input interface and a dataoutput interface of the whole apparatus.

Referring to FIG. 1e which shows integrated circuit chip apparatusprovided by the present disclosure, the integrated circuit chipapparatus may include: a main processing circuit and a plurality ofbasic processing circuits, where the plurality of basic processingcircuits are arranged in a form of array (an m*n array), the value rangeof m and n is an integer greater than or equal to 1, and at least one ofin and n is greater than or equal to 2. For the plurality of basicprocessing circuits that are arranged in the form of m*n array, eachbasic processing circuit may be connected to an adjacent basicprocessing circuit, and the main processing circuit may be connected tok basic processing circuits of the plurality of basic processingcircuits, where the k basic processing circuits may be: n basicprocessing circuits in a first row, n basic processing circuits in an mmrow, and/or m basic processing circuits in a first column. In theintegrated circuit chip apparatus shown in FIG. 1e , the main processingcircuit and/or the plurality of basic processing circuits may include adata type conversion circuit, and specifically, some basic processingcircuits of the plurality of basic processing circuits may include adata type conversion circuit. For instance, in an alternative example,the k basic processing circuits may be configured with a data typeconversion circuit. In this way, the n basic processing circuits mayperform a step of data type conversion on data of the m basic processingcircuits of a current column. This configuration may improvecomputational efficiency and reduce power consumption. For the n basicprocessing circuits in the first row, since they are the first toreceive data sent from the main processing circuit, by converting thereceived data into fixed point data, computations performed bysubsequent basic processing circuits and data transferred by thesubsequent basic processing circuits may be reduced. Similarly,configuring the m basic processing circuits of the first column with adata type conversion circuit may also have a technical effect of fewercomputations and less power consumption. In addition, according to thestructure, the main processing circuit may use a dynamic datatransferring strategy. For instance, the main processing circuit maybroadcast data to the in basic processing circuits of the first column,and distribute data to the n basic processing circuits of the first row.A technical effect of the example is that by transferring different datato the basic processing circuits via different data input ports, thebasic processing circuit may know the type of data merely according to areceiving port of the data without the need of distinguishing the typeof the received data.

The main processing circuit may be configured to perform neural networkcomputations in series, and transfer data to the basic processingcircuits that are connected to the main processing circuit; and thecomputations may include but is not limited to: accumulationcomputations, ALU computations, activation computations, and the like.

The plurality of basic processing circuits may be configured to performneural network computations in parallel according to data transferred,and transfer computation results to the main processing circuit throughthe basic processing circuits that are connected to the main processingcircuit. The neural network computations that are performed in parallelmay include but is not limited to: inner product computations, matrix orvector multiplication computations, and the like.

The main processing circuit may include: a data transferring circuit, adata receiving circuit or interface, where a data distribution circuitand a data broadcasting circuit may be integrated in the datatransferring circuit. In in certain applications, the data distributioncircuit and the data broadcasting circuit may be set independently, Datafor broadcasting refers to the data that need to be sent to each basicprocessing circuit. Data for distribution refers to the data that needto be sent to some basic processing circuit selectively. Specifically,taking a convolution computation as an instance, since convolutionalinput data of the convolution computation needs to be sent to all basicprocessing circuits, the convolutional input data is data forbroadcasting. Since a convolution kernel needs to be sent to some basicdata blocks selectively, the convolution kernel are data fordistribution. A method for selecting a basic processing circuit todistribute data may be determined by the main processing circuitaccording to the loads and other allocation methods. A method forbroadcasting refers to transferring data for broadcasting to each basicprocessing circuit by means of broadcasting. In some embodiments, thedata for broadcasting may be transferred to each basic processingcircuit by broadcasting for once or a plurality of times. The times ofbroadcasting are not restricted in the example of the presentdisclosure.: method for distributing refers to selectively transferringdata for distribution to some basic processing circuits.

The main processing circuit (as shown in FIG. 1c ) may include aregister and/or on-chip caching circuit, and the main processing circuitmay further include: a control circuit, a vector computing unit circuit,an ALU (Arithmetic and Logic Unit) circuit, an accumulator circuit, aDMA (Direct Memory Access) circuit, and the like. Of course, in incertain applications, the main processing circuit may further include aconversion circuit (e.g., a matrix transposition circuit), a datarearrangement circuit, an activation circuit, or the like.

Each basic processing circuit may include a basic register and/or abasic on-chip caching circuit; each basic processing circuit may furtherinclude one or more of an inner product computing unit circuit, a vectorcomputing unit circuit, an accumulator circuit, and the like. The innerproduct computing unit circuit, the vector computing unit circuit, andthe accumulator circuit may all be integrated circuits, and the innerproduct computing unit, the vector computing unit circuit, and theaccumulator circuit may also be circuits that are set independently.

Alternatively, the accumulator circuit of then basic processing circuitsof the m^(th) row may be configured to perform accumulation computationsof inner product computations. Since the basic processing circuits ofthe m^(th) row can receive multiplication results of all basicprocessing circuits of a current column, by using the n basic processingcircuits of the m^(th) row to perform accumulation computations of innerproduct computations, computing resources may be effectively allocated,and the power consumption may be reduced. This technical scheme may beparticularly suitable for a case where m is relatively large.

The main processing circuit may configure a circuit to perform data typeconversion. Specifically, a circuit may be configured in an explicitmanner or an implicit manner. For the explicit manner, the mainprocessing circuit can configure a special indication or instruction forconfirming to perform data type conversion, and if the basic processingcircuits do not receive the special indication or instruction, the basicprocessing circuits determine not to perform data type conversion. Datatype conversion may also be performed implicitly. For instance, when thebasic processing circuits receive floating point data and determine thatan inner product computation needs to be performed, the basic processingcircuits may convert the data into fixed point data. For the manner ofconfiguring explicitly, the special indication or instruction mayconfigure a descending sequence. Every time after passing a basicprocessing circuit, the value of the descending sequence may reduceby 1. The basic processing circuits may read the value of the descendingsequence, if the value is greater than zero, the basic processingcircuits may perform data type conversion, and if the value is equal toor less than zero, the basic processing circuits may not perform datatype conversion. This configuration is set according to the basicprocessing circuits arranged in the form of the array. For instance, forthe in basic processing circuits of the i^(th) column, the mainprocessing circuit requires the 5 basic processing circuits at the frontto perform data type conversion, in this case, the main processingcircuit sends a special instruction that includes a descending sequence,where an initial value of the descending sequence may be 5. Every timeafter passing a basic processing circuit, the value of the descendingsequence reduces by 1. At a fifth basic processing circuit, the value ofthe descending sequence is 1, and at a sixth basic processing circuit,the value of the descending sequence is 0. At this point, the sixthbasic processing circuit may not perform the data type conversion. Byusing this method, the main processing circuit may dynamically configurean execution subject and a count of execution times of data typeconversion.

An example of the present disclosure provides an integrated circuit chipapparatus. The integrated circuit chip apparatus may include a mainprocessing circuit (may also be referred to as a main unit) and aplurality of basic processing circuit (may also be referred to as basicunits). A structure of the example is shown in FIG. 1f where inside adashed box is an internal structure of the neural network computingapparatus, a gray arrow indicates a data transferring path between themain processing circuit and the basic processing circuits, and anoutlined arrow indicates a data transferring path between the respectivebasic processing circuits (adjacent basic processing circuits) in thebasic processing circuit array. The length and width of the basicprocessing circuit array may also be different. In other words, thevalues of in and n may be different, and may be the same. The values arenot restricted in the present disclosure.

FIG. Ig shows a circuit structure of a basic processing circuit. Adashed box in the figure indicates the border of the basic processingcircuit, a thick arrow that intersects the dashed box indicates a datainput pathway and a data output pathway (the arrow pointing to theinternal of the dashed box is the input pathway, and the arrow pointingto the external of the dashed box is the output pathway); a rectangularbox inside the dashed box indicates a storage unit circuit (registerand/or on-chip cache) including input data 1, input data 2, a result ofmultiplication or inner product, and accumulation data; and adiamond-shaped box indicates a computing unit circuit including amultiplier or inner product computing unit, and an adder.

In the present disclosure, the neural network computing apparatus mayinclude a main processing circuit and 16 basic processing circuits (the16 basic processing circuit are given by way of illustration, othernumber may be used in in certain applications).

In the present example, a basic processing circuit may have two datainput interfaces, two data output interfaces; in the followingdescription of the present example, a horizontal input interface (ahorizontal arrow pointing to a present unit as shown in FIG. 1f ) isreferred to as an input 0, a vertical input interface (a. vertical arrowpointing to a present unit as shown in FIG. 10 is referred to as aninput 1; a horizontal data output interface (a horizontal arrow pointingaway from a present unit as shown in FIG. 11) is referred to as anoutput 0, a vertical data output interface (a vertical arrow pointingaway from a present unit as shown in FIG. 1f ) is referred to as anoutput 1.

The data input interface and the data output interface may be connectedto different units respectively which may include the main processingcircuit and other basic processing circuits; in the present example,inputs 0 of the four basic processing circuits 0, 4, 8, 12 (see FIG. 1ffor the numbers) are connected to the data output interface of the mainprocessing circuit; in the present example, inputs 1 of the four basicprocessing circuits 0, 1, 2, 3 are connected to the data outputinterface of the main processing circuit; in the present example,outputs 1 of basic processing circuits 12,13,14,15 are connected to thedata input interface of the main processing circuit; connections of theoutput interfaces of the basic processing circuits and the inputinterfaces of other basic processing circuits of the present example canbe seen in FIG. 1f , which will be omitted here; specifically, an outputinterface S1 of a S unit is connected to an input interface P1 of a Punit, which indicates that the P unit can receive data that the S unitsends to the S1 interface via the P1 interface.

The present example may include a main processing circuit, where themain processing circuit may be connected to external apparatus (in otherwords, an input interface and an output interface both exist), some dataoutput interfaces of the main processing circuit may be connected to thedata input interfaces of some basic processing circuits; and some datainput interfaces of the main processing circuit may be connected to thedata output interfaces of some basic processing circuits.

An example of the present disclosure provides a method of usingintegrated circuit chip apparatus: data involved in the method providedby the present disclosure may be data of any data type. For instance,the data may be data represented by a floating point number of any bitwidth, or data represented by a fixed point number of any bit width.

FIG. 1d is a structural diagram of the fixed point data. FIG. 1d shows amethod of representing fixed point data. For a computing system, thestorage bit of one floating point data is 32 bits. For fixed point data,particularly a data representation using the floating point data shownin FIG. 1d , the storage bit of one fixed point data can be reduced toless than 16 bits, which may greatly reduce transferring overheadbetween computing units during conversion. In addition, for a computingunit, the storage space of data having fewer bits may be smaller, inother words, the storage overhead may he less, the amount ofcomputations may also be reduced, and the computational overhead may bereduced. In this case, the fixed point data shown in FIG. 1d may reducethe computational overhead and storage overhead. However, data typeconversion requires computational overhead, which will be referred to asconversion overhead below. For data that require a large amount ofcomputations and a large amount of storage, conversion overhead isalmost negligible compared with subsequent computational overhead,storage overhead, and transferring overhead. In this case, the presentdisclosure adopts a technical solution of converting data into fixedpoint data for data that require a large amount of computations and alarge amount of storage. On the contrary, for data that require a smallamount of computations and a small amount of storage, the data requireless computational overhead, storage overhead, and transferringoverhead. Since the precision of fixed point data is lower than theprecision of floating point data, if fixed point data is used, under thepremise that an amount of computations is relatively small, the fixedpoint data may be converted to floating point data to ensure theprecision of computations. In other words, the precision of computationsmay be improved by increasing a small amount of overhead.

Alternatively, a computation that needs to be completed in the basicprocessing circuits may be performed according to the following method:the main processing circuit may perform data type conversion on data,then transfer the data to the basic processing circuits for computing(for instance, the main processing circuit may convert a floating pointnumber to a fixed point number that has less bit width and transfer thefixed point number to the basic processing circuits. Technical effectsof doing so include that the bit width of data transferred may bereduced, the total count of bits being transferred may be reduced, thebasic processing circuits may achieve better efficiency with less powerconsumption when performing bit width fixed point computations).

After the basic processing circuits receive the data, the basicprocessing circuits may first perform data type conversion beforeperforming computations (for instance, the basic processing circuitsreceive a floating point number transferred from the main processingcircuit, then the basic processing circuits convert the floating pointnumber to a fixed point number for performing computations. In this way,the computational efficiency may be improved, and the power consumptionmay be reduced).

After the basic processing circuits obtain results by computing, theresults may first be subject to data type conversion and then betransferred to the main processing circuit (for instance, computationresults of a floating point number that are obtained by the basicprocessing circuits may first be converted into fixed point numbershaving less bit width, then the fixed point numbers are transferred tothe main processing circuit. Technical effects of this method includethat the bit width during the transferring process may be reduced, andbetter efficiency with less power consumption may be realized),

Specifically, a method of using the basic processing circuits (as shownin FIG. 2g ) may include: step 1: receiving, by the main processingcircuit, input data to be computed from the external of the apparatus;step 2: using, by the main processing circuit, various computationalcircuits of the unit such as the vector computational circuit, the innerproduct computing unit circuit, and the accumulator circuit to performcomputations on the data; step 3: transferring (as shown in FIG. 2h ),by the main processing circuit via the data output interface, the datato a basic processing circuit array (a set of all the basic processingcircuits is referred to as a basic processing circuit array);performing, by the basic processing circuit array, computations on thedata; a method of transferring data here may be transferring the samedata to some basic processing circuits directly, which in other words,may be a method of sequentially broadcasting; and a method oftransferring data here may also be transferring different data todifferent basic processing circuits, which in other words, may be amethod of distributing.

Alternatively, as shown in FIG. 2h , the step 3 may further include:step 3.1: receiving, by the basic processing circuits, data from one ora plurality of data input interfaces, and storing the data in theon-chip cache or register; step 3.2a: after the basic processingcircuits receive the data, computing, by the basic processing circuits,to obtain a computation result, and determining whether to output thecomputation result; alternatively, if the basic processing circuitsdetermine not to output the computation result, step 3.3a: storing, bythe basic processing circuits, the computation results in the on-chipcache or register; if the basic processing circuits determine to outputthe computation results, step 3.3b: outputting, by the basic processingcircuits, the computation results (the computation results may beintermediate results or final computation results) via the data outputinterface.

Alternatively, after the step 3.1, the method may further include: afterthe basic processing circuits receive the data, outputting the data bythe basic processing circuits via the data output interface of the unit;for instance, the basic processing circuits may transfer the receiveddata to other basic processing circuits that have not directly receiveddata from the main processing circuit.

The method may further include step 4: outputting, by the basicprocessing circuit array, the computation result to the main processingcircuit; and receiving, by the main processing circuit, output datareturned by the basic processing circuit array; alternatively, the mainprocessing circuit may continue to process the data received from thebasic processing circuit array (such as accumulating or activationoperating); when the main processing circuit does not need to continueto process the data or finishes processing the data, a step 5 may beperformed, which is: transferring, by the main processing circuit, aprocessing result to the external of the apparatus via the data outputinterface.

The circuit apparatus may be used to perform matrix-multiply-vectorcomputations, where the matrix-multiply-vector may be a vector obtainedby: performing inner product computations between each row of a matrixand a vector, and placing the obtained results according to acorresponding order.

Below is a description of performing multiplication of a matrix S with asize of M rows and L columns and a vector P with a length of L, which isshown in FIG. 2 b.

The present method may use all or some basic processing circuits of theneural network computing apparatus. It is assumed that K basicprocessing circuits are used; the main processing circuit may transferdata in all or some rows of the matrix S to each basic processingcircuit of the k basic processing circuits; and in an alternativeexample, each time, a control circuit of the main processing circuit maytransfer a number or some numbers of data in a row of the matrix S to abasic processing circuit. For instance, transferring a number at eachtime may be: for a basic processing circuit, a 1^(st) number in a 3^(rd)row may be transferred at a 1^(st) time, a 2^(nd) number in the 3^(rd)row may be transferred at a 2^(nd) time, a 3^(rd) number in the 3^(rd)row may be transferred at a 3^(rd) time, . . . ; or transferring somenumbers at each time may be: first two numbers (1^(st) and 2^(nd)numbers) in a 3^(rd) row may be transferred at a 1^(st) time, a 3^(rd)number and a 4^(th) number in the 3^(rd) row may be transferred at a2^(nd) time, a 5^(th) number and a 6^(th) number in the 3^(rd) row maybe transferred at a 3^(rd) time, . . . In an alternative example, eachtime, the control circuit of the main processing circuit may transfer anumber or some numbers of some rows of the matrix S to some basicprocessing circuits. For instance, for a basic processing circuit,1^(st) numbers in a 3^(rd), 4^(th) and 5^(th) rows may be transferred ata 1^(st) time, 2^(nd) numbers in the 3^(rd), 4^(th) raid 5^(th) rows maybe transferred at a 2^(nd) time, 3^(rd) numbers in the 3^(rd), 4^(th),and 5^(th) rows may be transferred at a 3^(rd) time, . . . ; or firsttwo numbers in a 3^(rd), 4^(th), and 5^(th) rows may be transferred at a1^(st) time, 3^(rd) numbers and 4^(th) numbers in the 3^(rd), 4^(th) and5^(th) rows may be transferred at a 2^(nd) time, 5^(th) numbers and6^(th) numbers in the 3^(rd), 4^(th), and 5^(th) rows may be transferredat a 3^(rd) time,

The control circuit of the main processing circuit may transfer data inthe vector P to a zeroth basic processing circuit successively; afterreceiving the data of the vector P, the zeroth basic processing circuitmay transfer the data to a next basic processing circuit that isconnected to the zeroth basic processing circuit, which is a basicprocessing circuit 1; specifically, some basic processing circuitscannot obtain data required for computations directly from the mainprocessing circuit, for instance, the basic processing circuit 1 in FIG.2i , which only has one data input interface that is connected to themain processing circuit, in this case, the basic processing circuit 1can only obtain data of the matrix S directly from the main processingcircuit, and has to depend on the basic processing circuit 0 for data ofthe vector P, similarly, after the basic processing circuit I receivesthe data., the basic processing circuit 1 may continue to output thedata of the vector P to a basic processing circuit 2.

Each basic processing circuit performs computations on the receiveddata, where the computations may include, but is not limited to: aninner product computation, a multiplication computation, an additioncomputation, and the like. In an alternative example, each time, thebasic processing circuit may perform multiplication on one or aplurality of groups of two data, then accumulate a result in theregister and/or on-chip cache. In an alternative example, each time, thebasic processing circuit may compute an inner product of one or aplurality of groups of two vectors, then accumulate a result in theregister and/or on-chip cache; after the basic processing circuitobtains a result by computing, the basic processing circuit may outputthe result through the data output interface (in other words, transferto another basic processing circuit that is connected to the basicprocessing circuit). In an alternative example, the computation resultmay be a final result or an intermediate result of an inner productcomputation.

Furthermore, after the basic processing circuit receives a computationresult from another basic processing circuit, the basic processingcircuit may transfer the data to yet another basic processing circuitthat is connected to the basic processing circuit or to the mainprocessing circuit; the main processing circuit may receive an innerproduct computation result transferred by each basic processing circuit,and process (which may be an accumulation computation, an activationcomputation, or the like) the result to obtain a final result.

Alternatively, the following describes an example of using the computingapparatus to realize a matrix-multiply-vector computation:

In an alternative example, a plurality of basic processing circuits usedin the method may be arranged according to a manner shown in FIG. 2i orFIG. 2 j.

As shown in FIG. 2b , a data type conversion circuit of the mainprocessing circuit may convert the matrix S and the matrix P into fixedpoint data and the control circuit of the main processing circuit maydivide M rows of data of the matrix S into K groups. An i^(th) basicprocessing circuit may be responsible for the computation of an i^(th)group (a set of rows in the group of data is referred to as Ai). Amethod of grouping the M rows of data is any grouping method withoutrepeated allocation.

In an alternative example, the following grouping method may be used:allocating a j^(th) row to a (j % K)^(th) (where % denotes a computationof taking a remainder) basic processing circuit.

As an alternative example, in a case where rows cannot be groupedevenly, some rows may be grouped evenly first, and the remaining rowsmay be allocated in any manner.

Specifically, the method of matrix-multiply-vector may include: eachtime, the control circuit of the main processing circuit maysuccessively transfer data of some or all rows in the matrix S tocorresponding basic processing circuits.

In an alternative example, each time, the control circuit of the mainprocessing circuit may transfer one or a plurality of data in a row ofdata of an i^(th) group of data. Mi that the i^(th) basic processingcircuit is responsible for to the i^(th) basic processing circuit.

In an alternative example, each time, the control circuit of the mainprocessing circuit nay transfer one or a plurality of data in each rowof some or all rows of the i^(th) group of data Mi that the i^(th) basicprocessing circuit is responsible for to the i^(th) basic processingcircuit.

The control circuit of the main processing circuit may successivelytransfer data in the vector P to the first basic processing circuit.

In an alternative example, each time, the control circuit of the mainprocessing circuit may transfer one or a plurality of data in the vectorP.

After the i^(th) basic processing circuit receives the data of thevector P, the i^(th) basic processing circuit may transfer the data ofthe vector P to a i+1^(th) basic processing circuit that is connected tothe i^(th) basic processing circuit; after each basic processing circuitreceives one or a plurality of data from one or a plurality of rows ofthe matrix S and one or a plurality of data from the vector P, the basicprocessing circuit may perform computations (include but is not limitedto multiplication or addition).

In an alternative example, each time, the basic processing circuit mayperform multiplication of one or a plurality of groups of two data, thenaccumulate a result in the register and/or on-chip cache. In analternative example, each time, the basic processing circuit may computean inner product of one or a plurality of groups of two vectors, thenaccumulate a result in the register and/or on-chip cache. In analternative example, data received by the basic processing circuit maybe an intermediate result, where the intermediate result may be storedin the register and/or on-chip cache; and furthermore, the basicprocessing circuit may transfer a local computation result to anotherbasic processing circuit or to the main processing circuit.

In an alternative example, corresponding to a structure shown in FIG. 2i, only the output interface of a last basic processing circuit in eachcolumn is connected to the main processing circuit, in this case, onlythe last basic processing circuit may directly transfer a localcomputation result to the main processing circuit, computation resultsof other basic processing circuits may all need to be transferred to asubsequent basic processing circuit, and then be transferred by thesubsequent basic processing circuit to a basic processing circuit afterthe subsequent basic processing circuit, until the computation resultsare transferred to the last basic processing circuit. The last basicprocessing circuit may accumulate a local computation result withreceived results from another basic processing circuit of a presentcolumn to obtain an intermediate result, and transfer the intermediateresult to the main processing circuit. Of course, the last basicprocessing circuit may also transfer results of other basic processingcircuits of the present column and a local processing result directly tothe main processing circuit.

In an alternative example, corresponding to a structure of FIG. 2j ,each basic processing circuit has an output interface that is connectedto the main processing circuit, in this case, each basic processingcircuit can transfer a local computation result to the main processingcircuit directly. After the basic processing circuit receives acomputation result from another basic processing circuit, the basicprocessing circuit may transfer the data to yet another basic processingcircuit that is connected to the basic processing circuit or to the mainprocessing circuit. The main processing circuit may receive a result ofM inner product computations to be used as a computation result ofmatrix-multiply-vector.

Alternatively, the present disclosure may use the circuit apparatus toperform a matrix-multiply-matrix computation, which is as follows:

below is a description of performing multiplication of a matrix S with asize of M rows and L columns and a matrix P with a size of L rows and Ncolumns, where each row of the matrix S is as long as each column of thematrix P, which is as shown in FIG. 2e . The method may use theabove-mentioned apparatus. An example as shown in FIG. 1f is as follow:performing, by the data type conversion circuit of the main processingcircuit, data type conversion on the matrix S and the matrix P;alternatively, the control circuit of the main processing circuit maytransfer data of some or all rows of the matrix S to basic processingcircuits that are directly connected to the main processing circuit viahorizontal data input interfaces (for instance, gray vertical datapathways at the top of FIG. 1f ). In an alternative example, each time,the control circuit of the main processing circuit may transfer a numberor some numbers of data in a row of the matrix S to a basic processingcircuit, for instance, for a basic processing circuit, a 1^(st) numberin a 3^(rd) row may be transferred at a 1^(st) time, a 2^(nd) number inthe 3^(rd) row may be transferred at a 2^(nd) time, a 3^(rd) number inthe 3^(rd) row may be transferred at a 3^(rd) time, . . . ; or first twonumbers in a 3^(rd) row may be transferred at a is time, a 3^(rd) numberand a 4^(th) number in the 3^(rd) row may be transferred at a 2^(nd)time, a 5^(th) number and a 6^(th) number in the 3^(rd) row may betransferred at a 3^(rd) time, . . . In an alternative example, eachtime, the control circuit of the main processing circuit may transfer anumber or some numbers of some rows of data of the matrix S to a basicprocessing circuit, for instance, for a basic processing circuit, 1^(st)numbers in a 3^(rd), 4^(th), and 5^(th) rows may be transferred at a1^(st) time. 2^(nd) numbers in the 3^(rd), 4^(th) and 5^(th) rows may betransferred at a 2^(nd) time, 3^(rd) numbers in the 3^(rd), 4^(th), and5^(th) rows may be transferred at a 3^(rd) time, . . . ; or first twonumbers in a 3^(rd), 4^(th), and 5^(th) rows may be transferred at a1^(st) time, 3^(rd) numbers and 4^(th) numbers in the 3^(rd), 4^(th),and 5^(th) rows may be transferred at a 2^(nd) time, 5^(th) numbers and6^(th) numbers in the 3rd, 4^(th) and 5^(th) rows may be transferred ata 3^(rd) time, . . .

The control circuit of the main processing circuit may transfer data ofsome or all columns of the matrix P to basic processing circuits thatare directly connected to the main processing circuit via vertical datainput interfaces (for instance, gray horizontal data pathways on theleft of the basic processing circuit array shown in FIG. 1f ). In analternative example, each time, the control circuit of the mainprocessing circuit may transfer a number or some numbers of a column ofthe matrix P to a basic processing circuit; for instance, for a basicprocessing circuit, a 1^(st) number in a 3^(rd) column may betransferred at a 1^(st) time, a 2^(nd) number in the 3^(rd) column maybe transferred at a 2^(nd) time, a 3^(rd) number in the 3^(rd) columnmay be transferred at a 3^(rd) time, . . . ; or first two numbers in a3^(rd) column may be transferred at a 1^(st) time, a 3^(rd) number and a4^(th) number in the 3^(rd) column may be transferred at a 2^(nd) time,a 5^(th) number and a 6^(th) number in the 3^(rd) column may betransferred at a 3^(rd) time, in an alternative example, each time, thecontrol circuit of the main processing circuit may transfer a number orsome numbers of some columns of data of the matrix P to a basicprocessing circuit, for instance, for a basic processing circuit, 1^(st)numbers in a 3^(rd) , 4^(th), and 5^(th) columns may be transferred at a1^(st) time. 2^(nd) numbers in the 3^(rd), 4^(th), and 5^(th) columnsmay be transferred at a 2^(nd) time, 3^(rd) numbers in the 3^(rd),4^(th) and 5^(th) columns may be transferred at a 3^(rd) time, . . . ;or first two numbers in a 3^(rd), 4^(th), and 5^(th) columns may betransferred at a 1^(st) time, 3^(rd) numbers and 4^(th) numbers in the3^(rd), 4^(th), and 5^(th) columns may be transferred at a 2^(nd) time,5^(th) numbers and 6^(th) numbers in the 3^(rd), 4^(th), and 5^(th)columns may be transferred at a 3^(rd) time, . . . ; and after the basicprocessing circuit receives the data of the matrix S, the basicprocessing circuit may transfer the data to a subsequent basicprocessing circuit that is connected to the basic processing circuitvia, a horizontal data output interface of the basic processing circuit(for instance, horizontal data pathways filled in white at the center ofthe basic processing circuit array shown in FIG. 1f ). After the basicprocessing circuit receives the data of the matrix P, the basicprocessing circuit may transfer the data to a subsequent basicprocessing circuit that is connected to the basic processing circuit viaa vertical data output interface of the basic processing circuit (forinstance, vertical data pathways filled in white at the center of thebasic processing circuit array shown in FIG. 1f ).

Then, each basic processing circuit performs computations on receiveddata. In an alternative example, each time, the basic processing circuitmay perform multiplication of one or a plurality of groups of two data,then accumulate a result in the register and/or on-chip cache. In analternative example, each time, the basic processing circuit may computean inner product of one or a plurality of groups of two vectors, thenaccumulate a result in the register and/or on-chip cache; furthermore,after the basic processing circuit obtains a result by computing, thebasic processing circuit may output the result through the data outputinterface.

In an alternative example, the computation result may be a final resultor an intermediate result of an inner product computation; specifically,if the basic processing circuit has an output interface that is directlyconnected to the main processing circuit, the basic processing circuitmay output the result via the interface, if no, the basic processingcircuit may output the result towards a basic processing circuit thatcan output to the main processing circuit directly. For instance, inFIG. 1f , basic processing circuits at a bottom row can transfer resultsto the main processing circuit, and other basic processing circuits maytransfer results downwards via vertical output interfaces.

Furthermore, after the basic processing circuit receives a computationresult from another basic processing circuit, the basic processingcircuit may transfer the data to yet another basic processing circuitthat is connected to the basic processing circuit or to the mainprocessing circuit; specifically, the basic processing circuit mayoutput a result towards a direction to the main processing circuit, forinstance, in FIG. 1f , the basic processing circuits at a bottom row cantransfer results to the main processing circuit, and other basicprocessing circuits may transfer results downwards via vertical outputinterfaces; the main processing circuit may receive an inner productcomputation result transferred by each basic processing circuit toobtain an output result.

Alternatively, the present disclosure further provides an example ofmethod of matrix-multiply-matrix, which is as follows: the method uses abasic processing circuit array arranged according to the manner shown inFIG. 1f . It is assumed that there are h rows and w columns. The methodmay include: performing, by the data type conversion circuit of the mainprocessing circuit, data type conversion on the matrix S and the matrixP; the control circuit of the main processing circuit may divide h rowsof data of the matrix S into h groups. An i^(th) basic processingcircuit may be responsible for the computation of an i^(th) group (a setof rows in the group of data is referred to as Hi); a method of groupingthe h rows of data is any grouping method without repeated allocation,

In an alternative example, the following allocation method may be used:the control circuit of the main processing circuit allocates a j^(th)row to a j%K^(th) basic processing circuit; as an alternative example,in a case where rows cannot be grouped evenly, some rows may be groupedevenly first, and the remaining rows may be allocated in any manner.

The control circuit of the main processing circuit may divide W columnsof data of the matrix P into w groups. The i^(th) basic processingcircuit may be responsible for the computation of an i^(th) group (a setof rows in the group of data is referred to as Wi.); a method ofgrouping the W columns of data is any grouping method without repeatedallocation. In an alternative example, the following allocation methodmay be used: the control circuit of the main processing circuitallocates a j^(th) row to a j % w^(th) basic processing circuit; as analternative example, in a case where columns cannot be grouped evenly,some columns may be grouped evenly first, and the remaining columns maybe allocated in any manner.

Alternatively, the control circuit of the main processing circuit maytransfer data in all or some rows of the matrix S to each basicprocessing circuit in each row of the basic processing circuit array. Inan alternative example, each time, the control circuit of the mainprocessing circuit may transfer one or a plurality of data in a row ofdata of an i^(th) group of data Hi that a 1^(st) basic processingcircuit of an i^(th) row of the basic processing circuit array isresponsible for to the 1^(st) basic processing circuit. In analternative example, each time, the control circuit of the mainprocessing circuit may transfer one or a plurality of data in each rowof some or all rows of the i^(th) group of data Hi that the 1^(st) basicprocessing circuit of the i^(th) row of the basic processing circuitarray is responsible for to the 1^(t) basic processing circuit;alternatively, the control circuit of the main processing circuit maytransfer data in some or all columns of the matrix P to a 1^(st) basicprocessing circuit in each column of the basic processing circuit array.In an alternative example, each time, the control circuit of the mainprocessing circuit may transfer one or a plurality of data in a columnof data of an i^(th) group of data Wi that a 1^(st) basic processingcircuit of the basic processing circuit array is responsible for to the1^(st) basic processing circuit. In an alternative example, each time,the control circuit of the main processing circuit may transfer one or aplurality of data in each column of some or all columns of an i^(th)group of data Ni that the i^(th) basic processing circuit of the basicprocessing circuit array is responsible for to the i^(th) basicprocessing circuit; and after the basic processing circuit receives thedata of the matrix S, the basic processing circuit may transfer the datato a subsequent basic processing circuit that is connected to the basicprocessing circuit via a horizontal data output interface of the basicprocessing circuit (for instance, horizontal data pathways filled inwhite at the center of the basic processing circuit array shown in FIG.1D. After the basic processing circuit receives the data of the matrixP, the basic processing circuit may transfer the data to a subsequentbasic processing circuit that is connected to the basic processingcircuit via a vertical data output interface of the basic processingcircuit (for instance, vertical data pathways filled in white at thecenter of the basic processing circuit array shown in FIG. 1f ).

Furthermore, each basic processing circuit performs computations onreceived data. In an alternative example, each time, the basicprocessing circuit may perform multiplication of one or a plurality ofgroups of two data, then accumulate a result in the register and/oron-chip cache. In an alternative example, each time, the basicprocessing circuit may compute an inner product of one or a plurality ofgroups of two vectors, then accumulate a result in the register and/oron-chip cache; yet furthermore, after the basic processing circuitobtains a result by computing, the basic processing circuit may outputthe result through the data output interface. In an alternative example,the computation result may be a final result or an intermediate resultof an inner product computation; specifically, if the basic processingcircuit has an output interface that is directly connected to the mainprocessing circuit, the basic processing circuit may output the resultvia the interface, if no, the basic processing circuit may output theresult towards a basic processing circuit that can output to the mainprocessing circuit directly, for instance, basic processing circuits ata bottom row can transfer results to the main processing circuitdirectly, and other basic processing circuits may transfer resultsdownwards via vertical output interfaces.

Still furthermore, after the basic processing circuit receives acomputation result from another basic processing circuit, the basicprocessing circuit may transfer the data to yet another basic processingcircuit that is connected to the basic processing circuit or to the mainprocessing circuit; specifically, the basic processing circuit mayoutput the result towards a direction to the main processing circuit.For instance, the basic processing circuits at the bottom row cantransfer results to the main processing circuit, and other basicprocessing circuits may transfer results downwards via vertical outputinterfaces.

Furthermore, the main processing circuit may receive an inner productcomputation result transferred by each basic processing circuit toobtain an output result.

The words “horizontal”, “vertical”, and the like used in the descriptionabove are only for the purpose of explaining the example shown in FIG.1n in certain applications, it is only needed to ensure that“horizontal” and “vertical” interfaces of each unit represent twodifferent interfaces.

Alternatively, the present disclosure can use the circuit apparatus toperform a fully connected computation: if input data of a fullyconnected layer is a vector (in other words, a case where input of aneural network is a single sample), a weight matrix of the fullyconnected layer serves as a matrix S, an input vector serves as a vectorP, a matrix-multiply-vector computation may be performed according tothe method of the apparatus; if the input data of the fully connectedlayer is a matrix (in other words, a case where the input of the neuralnetwork is a plurality of sample), the weight matrix of the fullyconnected layer serves as the matrix S, the input vector serves as amatrix P, or the weight matrix of the fully connected layer serves asthe matrix P, and the input vector serves as the matrix S. A computationmay be performed according to the matrix-multiply-matrix computation ofthe apparatus.

Alternatively, the present disclosure can use the circuit apparatus toperform a convolution computation: the following is a description of theconvolution computation, a block in the drawing below represents onedata, input data is shown by FIG. 3c (N samples, each sample has Cchannels, and a feature map of each channel has a height of I-I and awidth of W), and a weight, which is a convolution kernel, is shown byFIG. 3d (with M convolution kernels, and each convolution kernel has Cchannels with a height being KH and a width being KW). For the N samplesof the input data, rules for convolution computations are the same.Below is an explanation of a process of performing a convolutioncomputation on a sample. Each of the M convolution kernels may besubject to the same computation on a sample, each convolution kernel mayobtain a plane feature map by computations, and the M convolutionkernels may obtain M plane feature maps by computations (for a sample,output of convolution is M feature maps), for a convolution kernel, aninner product computation may be performed on each plane of a sample,and the convolution kernel may slide in a direction of H and a directionof W, for instance, FIG. 3e is a figure showing that a convolutionkernel performs an inner product computation at a position at lowerright corner of a sample of input data; FIG. 3f shows a position ofconvolution sliding leftwards for one grid, and FIG. 3g shows a positionof convolution sliding upwards for one grid.

The method is explained by using the apparatus of FIG. 1f ; the datatype conversion circuit of the main processing circuit may convert datain some or all convolution kernels of the weight to fixed point data,the control circuit of the main processing circuit may transfer data ofsome or all convolution kernels of the weight to basic processingcircuits that are directly connected to the main processing circuit viahorizontal data input interfaces (for instance, gray vertical datapathways at the top of FIG. 1f ). In an alternative example, each time,the control circuit of the main processing circuit may transfer a numberor some numbers of data in a convolution kernel of the weight to a basicprocessing circuit, for instance, for a basic processing circuit, a1^(st) number in a 3^(rd) row may be transferred at a 1^(st) time, a2^(nd) number in the 3^(rd) row may be transferred at a 2^(nd) time, a3^(rd) number in the 3^(rd) row may be transferred at a 3^(rd) time, . .. , or first two numbers in a 3^(rd) row may be transferred at 1^(st)time, a 3^(rd) number and a 4^(th) number in the 3^(rd) row may betransferred at a 2^(nd) time, a 5^(th) number and a 6 ^(th) number inthe 3^(rd) row may be transferred at a 3^(rd) time, . . . ; another casein an alternative example may be that, each time, the control circuit ofthe main processing circuit may transfer a number or some numbers ofdata of some convolution kernels of the weight to a basic processingcircuit, for instance, for a basic processing circuit, 1^(st) numbers ina 3^(rd), 4^(th), and 5 ^(th) rows may be transferred at a 1^(st) time,2^(nd) numbers in the 3^(rd), 4^(th) and 5^(th) rows may be transferredat a 2^(nd) time, 3^(rd) numbers in the 3^(rd), 4^(th), and 5^(th) rowsmay be transferred at a 3^(rd) time, . . . , or first two numbers in a3^(rd), 4^(th), and 5^(th) rows may be transferred at a 1^(st) time,3^(rd) numbers and 4 ^(th) numbers in the3^(rd), 4^(th) and 5^(th) rowsmay be transferred at a 2^(nd) time, 5^(th) numbers and 6^(th) numbersin the 3^(rd), 4^(th), and 5^(th) rows may be transferred at a 3^(rd)time, . . . ; the control circuit of the main processing circuit maydivide input data according to positions of convolution, and maytransfer data of some or all positions of convolution in the input datato the basic processing circuits that are directly connected to the mainprocessing circuit via the vertical data input interfaces (for instance,the gray horizontal data pathways on the left of the basic processingcircuit array shown in FIG. 1f ). In an alternative example, each time,the control circuit of the main processing circuit may transfer a numberor some numbers of data of a position of convolution in the input datato a basic processing circuit; for instance, for a basic processingcircuit, a 1^(st) number in a 3^(rd) column may be transferred at a1^(st) time, a 2^(nd) number in the 3^(rd) column may be transferred ata 2^(nd) time, a 3^(rd) number in the 3^(rd) column may be transferredat a 3^(rd) time, . . . , or first two numbers in a 3^(rd) column may betransferred at a 1^(st) time, a 3^(rd) number and a 4^(th) number in the3^(rd) column may be transferred at a 2^(rd) time, a 5^(th) number and a6^(th) number in the 3^(rd) column may be transferred at a 3^(rd) tune,

Another case in an alternative example may be that, each time, thecontrol circuit of the main processing circuit may transfer a number orsome numbers of data of some positions of convolution in the input datato a basic processing circuit, for instance, for a basic processingcircuit, 1^(st) numbers in a 3^(rd), 4^(th), and 5^(th) columns may betransferred at a 1^(st) time, 2^(nd) numbers in the 3^(rd), 4^(th) and5^(th) columns may be transferred at a 2^(nd) time, 3^(rd) numbers inthe 3^(rd), 4^(th), and 5^(th) columns may be transferred at a 3^(rd)time, . . . , or first two numbers in a 3^(rd), 4^(th) and 5^(th)columns may be transferred at a 1^(st) time, 3′^(d) numbers and 4^(th)numbers in the 3^(rd), 4^(th) and 5^(th) columns may he transferred at a2^(nd) time, 5^(th) numbers and 6^(th) numbers in the 3^(rd), 4^(th),and 5^(th) columns may he transferred at a 3^(rd) time, . . . .

After the basic processing circuit receives the data of the weight, thebasic processing circuit may transfer the data to a subsequent basicprocessing circuit that is connected to the basic processing circuit viaa horizontal data output interface of the basic processing circuit (forinstance, horizontal data pathways filled in white at the center of thebasic processing circuit array shown in FIG. 1f ); after the basicprocessing circuit receives the input data, the basic processing circuitmay transfer the data to a subsequent basic processing circuit that isconnected to the basic processing circuit via a vertical data outputinterface of the basic processing circuit (for instance, vertical datapathways filled in white at the center of the basic processing circuitarray shown in FIG. 1f ); furthermore, each basic processing circuitperforms computations on received data. In an alternative example, eachtime, the basic processing circuit may perform multiplication of one ora plurality of groups of two data, then accumulate a result in theregister and/or on-chip cache. In an alternative example, each time, thebasic processing circuit may compute an inner product of one or aplurality of groups of two vectors, then accumulate a result in theregister and/or on-chip cache; yet furthermore, after the basicprocessing circuit obtains a result by computing, the basic processingcircuit may output the result through the data output interface. In analternative example, the computation result may be a final result or anintermediate result of an inner product computation; specifically, ifthe basic processing circuit has an output interface that is directlyconnected to the main processing circuit, the basic processing circuitmay output the result via the interface, if no, the basic processingcircuit may output the result towards a basic processing circuit thatcan output to the main processing circuit directly, For instance, inFIG. 1f basic processing circuits at a bottom row can transfer resultsto the main processing circuit, and other basic processing circuits maytransfer results downwards via vertical output interfaces.

After the basic processing circuit receives a computation result fromanother basic processing circuit, the basic processing circuit maytransfer the data to yet another basic processing circuit that isconnected to the basic processing circuit or to the main processingcircuit; specifically, the basic processing circuit may output a resulttowards a direction to the main processing circuit (for instance, basicprocessing circuits at a bottom row can transfer results to the mainprocessing circuit directly, and other basic processing circuits maytransfer results downwards via vertical output interfaces); and the mainprocessing circuit may receive an inner product computation resulttransferred by each basic processing circuit to obtain an output result.

Alternatively, the present disclosure provides a method of using thecircuit apparatus to perform an operation of giving a bias, which mayinclude: the vector computing unit circuit of the main processingcircuit may be used to realize a function of adding two vectors togetheror adding two matrices together; and the vector computing unit circuitof the main processing circuit may be used to realize a function ofadding a vector to each row of a matrix, or to each column of a matrix.

In an alternative example, the matrix may be from a result of amatrix-multiply-matrix computation performed by the apparatus. In analternative example, the vector may be from a result of amatrix-multiply-vector computation performed by the apparatus; and in analternative example, the matrix may be from data received from theexternal by the main processing circuit of the apparatus.

In an alternative example, the vector may be from data received from theexternal by the main processing circuit of the apparatus.

It should be understood that, data sources of the matrix and/or thevector may include but is not limited to the above-mentioned datasources.

Alternatively, the present disclosure provides a method of using thecircuit apparatus to perform an activation function computation, wherethe method which may include: using the activation circuit of the mainprocessing circuit to input a vector, and obtain an activation vector ofthe vector by computing.

In an alternative example, the activation circuit of the main processingcircuit may obtain a numerical value for each value of an input vectorthrough an activation function (input of the activation function is anumerical value, and output is also a numerical value) by computing, andoutput the numerical value to a corresponding position of an outputvector. In an alternative example, the activation function may be:y=max(m, x), where x is an input numerical value, y is an outputnumerical value, and m is a constant. In an alternative example, theactivation function may be: y=tan h(x), where x is an input numericalvalue, and y is an output numerical value. In an alternative example,the activation function may be: y=sigmoid(x), where x is an inputnumerical value, y is an output numerical value. In an alternativeexample, the activation function may be a piecewise linear function; andin an alternative example, the activation function may be a function ofrandomly inputting a number and outputting a number.

In an alternative example, a source of the input vector may include (butis not limited to): an external data source of the apparatus.

In an alternative example, the input data may be from a computationresult of matrix-multiply-vector performed by the apparatus.

In an alternative example, the input data may be from a computationresult of matrix-multiply-matrix performed by the apparatus, or acomputation result of the main processing circuit of the apparatus

In an alternative example, the input data may be from a computationresult obtained after the main processing circuit of the apparatus isbiased.

Alternatively, the present disclosure provides a method of using theapparatus to realize BLAS(Basic Linear Algebra Subprograms), where themethod may include: a GEMM computation refers to a computation ofmatrix-matrix multiplication in a BLAS library. A common representationof the computation is C=alpha*op(S)*op(P)+beta*C, where A and B are twoinput matrices, C is an output matrix, alpha and beta are scalars, oprepresents an operation performed on the matrix S or P, in addition,other supporting integers may be used as parameters to explain the widthand height of the matrices A and B; specifically, a step of using theapparatus to realize the GEMM computation may be: before performing anop operation, the main processing circuit may perform data typeconversion on the input matrix S and the matrix P; the conversioncircuit of the main processing circuit may perform corresponding opoperations on the matrix S and the matrix P respectively. In analternative example, op may be a matrix transposition operation whichmay be realized by using a vector computation function or datarearrangement function of the main processing circuit (it has beenmentioned that the main processing circuit has a data rearrangementcircuit), and in in certain applications, the op may also be realizedthrough the conversion circuit directly, taking the matrix transpositionoperation as an instance, the op operation may be realized by the matrixtransposition circuit directly.

As an alternative example, op of a matrix may be null, and the opoperation of the matrix may not be performed; the computation method ofmatrix-multiply-matrix may be used to perform a matrix multiplicationcomputation between op(S) and op(P); the arithmetic and logic circuit ofthe main processing circuit may be used to perform an operation ofmultiplying each value in a result of op(S)*op(P) by alpha; as analternative example, in case when alpha is 1, the operation ofmultiplying by alpha may not be performed; the arithmetic and logiccircuit of the main processing circuit may be used to realize acomputation of beta*C; as an alternative example, in case when beta is1, the operation of multiplying by beta may not be performed; thearithmetic and logic circuit of the main processing circuit may be usedto realize a step of adding corresponding positions of matricesalpheop(S)*op(P) and beta*C together; as an alternative example, in casewhen beta is 0, the operation of adding may not be performed.

Alternatively, a GEMV computation refers to a computation ofmatrix-vector multiplication in a BLAS library. A common representationof the computation is C=alpha*op(S)*P+beta*C, where S is an inputmatrix, P is an input vector, C is an output vector, alpha and beta arescalars, and op represents an operation performed on the matrix S;specifically, a step of using the apparatus to realize the GEMVcomputation may be: before performing an op operation, the mainprocessing circuit may perform data type conversion on the input matrixS and the matrix P; the conversion circuit of the main processingcircuit may perform a corresponding op operation on the matrix S; as analternative example, op may be a matrix transposition operation; thematrix transposition circuit of the main processing circuit may be usedto realize the matrix transposition operation; as an alternativeexample, op of a matrix may be null, and the op operation may not beperformed; the computation method of matrix-multiply-vector may be usedto perform a matrix-vector multiplication between the matrix op(S) andthe vector op(P); the arithmetic and logic circuit of the mainprocessing circuit may be used to perform an operation of multiplyingeach value in a result of op(S)*P by alpha; as an alternative example,in case when alpha is 1, the operation of multiplying by alpha may notbe performed; the arithmetic and logic circuit of the main processingcircuit may be used to realize a computation of beta*C; as analternative example, in case when beta is 1, the operation ofmultiplying by beta may not be performed; the arithmetic and logiccircuit of the main processing circuit may be used to realize a step ofadding corresponding positions of matrices alpha*op(S)*P and beta*Ctogether; and as an alternative example, in case when beta is 0, theoperation of adding may not be performed.

Alternatively, the present disclosure provides a method of realizingdata type conversion, where the method may include: the data typeconversion circuit of the main processing circuit may be used to realizedata type conversion.

In an alternative example, a form of data type conversion may includebut is not limited to: converting a floating point number to a fixedpoint number, converting a fixed point number to a floating pointnumber, and the like.

Alternatively, the present disclosure provides a method of updating aweight, where the method may include: using the vector computing unitcircuit of the main processing circuit to realize a function of weightupdating during neural network training, specifically, the weightupdating refers to a method of using a gradient of the weight to updatethe weight.

In an alternative example, the vector computing unit circuit of the mainprocessing circuit may be used to perform addition and subtractioncomputations on the weight and the gradient of the weight, which are twovectors, to obtain a computation result, and the computation result isan updated weight.

In an alternative example, the vector computing unit circuit of the mainprocessing circuit may be used to perform addition and subtractioncomputations on the weight and the gradient of the weight, which are twovectors, to obtain a computation result, and the computation result isan updated weight.

In an alternative example, the gradient of the weight may first be usedfor computing to obtain a group of momentum, then the momentum and theweight may be used to perform addition and subtraction computations toobtain an updated weight.

Alternatively, the present disclosure further provides a method ofrealizing a back computation of a fully connected layer, where themethod may include: the back computation of the fully connected layermay he divided into two parts, as shown in FIG. 4a . FIG. 4a shows aprocess of a forward computation of the fully connected layer.

Alternatively, the present disclosure may realize a back operation of aconvolutional layer, which is as follows: the back computation of theconvolutional layer may be divided into two parts, FIG. 4a shows aprocess of a forward computation of the convolutional layer, and. FIG.4h shows a process of the back computation of the convolutional layer.

The back computations of the convolutional layers as shown in FIG. 4aand FIG. 4h may be performed by using the apparatus of FIG. 1e and theapparatus of FIG. 1f . When performing a forward computation or a backcomputation which in fact is a plurality of computations of a neuralnetwork, the plurality of computations may include but is not limited toone or more of: matrix-multiply-matrix, matrix-multiply-vector,convolution computation, activation computation, and the like.

FIG. 4a shows a forward computation of neural network provided by anexample of the present disclosure, where each layer may use input dataand a weight of the layer to obtain corresponding output data byperforming computations according to a computation rule designated by atype of the layer; the forward computation (also referred to asinference) of a neural network is a process of obtaining output data byprocessing input data of each layer in a layer by layer manner, andperforming computations, which has the following characteristics:

1) input of a layer:

input of a layer may be input data of a neural network;

input of a layer may he output data of another layer;

input of a layer may be output of the present layer at a last time(corresponding to a case of a recurrent neural network);

a layer may obtain input from a plurality of above-mentioned inputsources simultaneously;

2) output of a layer:

output of a layer may serve as an output result of a neural network;

output of a layer may be input of another layer;

output of a layer may be input of the present layer at a next time(corresponding to a case of a recurrent neural network);

output of a layer may output a result to the plurality ofabove-mentioned output directions.

Specifically, a type of a computation of a layer in the neural networkmay include but is not limited to:

a convolutional layer (in other words, a convolution computation is tobe performed);

a fully connected layer (in other words, a fully connected computationis to be performed);

a normalization layer: including a LRN (Local Response Normalization)layer, a BN (Batch Normalization) layer, and other types;

a pooling layer; and

an activation layer: including but is not limited to the followingtypes: a Sigmoid layer a ReLU layer, a PReLu layer, a LeakyReLu layer,and a Tan h layer.

Alternatively, FIG. 4b shows a back computation of a layer of a neuralnetwork provided by the present disclosure. Two parts of computationsmay need to be performed in the back computation of each layer: a firstpart is to compute a gradient (a weight that is used in a weightupdating step to update a weight of a current layer) of a weight byusing a output data gradient that may be in a sparse representation andinput data that may be in a sparse representation, and a second part isto compute an input data gradient (to be used as output data of a nextlayer in the back computation so that the back computation can beperformed) by using an output data gradient that may be in a sparserepresentation and a weight that may be in a sparse representation; theback computation may follow an order that is opposite to an order of aforward computation to transfer a gradient reversely from a last layer.

In an alternative example, an output data gradient obtained from theback computation of a layer may be from: a gradient returned by a lastlost function (or cost function) of the neural network; an input datagradient of another layer; or, an input data gradient of the presentlayer at a last time (corresponding to a case of a recurrent neuralnetwork).

Further, a layer may obtain an output data gradient from a plurality ofabove-mentioned sources simultaneously.

After the back computation of the neural network is completed, agradient of a weight of each layer is obtained. In this step, a firstinput cache and a second input cache may be configured to store a weightand a gradient of the weight of a layer, then use the gradient of theweight in a computing unit to update the weight.

The above-mentioned computation is a computation of a layer of theneural network. For a multi-layer neural network, a realization may bethat, in a forward computation, after the forward computation of aprevious layer of the artificial neural network is completed, acomputation instruction of a next layer may use output data obtained bya computing unit as input data of the next layer to perform acomputation (or perform some operations on the output data then use theoutput data as input data of the next layer), at the same time, replacea weight with a weight of the next layer. In a back computation, afterthe back computation of a previous layer of the artificial neuralnetwork is completed, a computation instruction of a next layer may usean input data gradient obtained by a computing unit as an output datagradient of the next layer to perform a computation (or perform someoperations on the input data gradient then use the input data gradientas output data gradient of the next layer), at the same time, replace aweight with a weight of the next layer. (Shown in FIG. 4a and FIG. 4b .FIG. 4b shows the back computation and FIG. 4a shows the forwardcomputation)

Alternatively, the present disclosure may further realize a method ofrepresenting fixed point data, which is as follows: the method of fixedpoint conversion refers to converting a data representation of a datablock in a network into a data representation having a fixed positionfor the decimal point (a manner of placing 0/1 bit of data that aremapped to circuit apparatus).

As an alternative example, a plurality groups of data may constitute aplurality of data blocks. The plurality of data blocks as a whole may berepresented in the fixed point type by following the same fixed pointrepresentation method.

FIG. 1d shows a method of representing a fixed point data structurehaving few digits according to an example of the present disclosure. Theposition of 1 Bit represents symbol, the position of M represents aninteger part, and the position of N represents a decimal part. Comparedwith a 32-bit floating point number representation, the presentdisclosure uses a fixed point data representation having few digits. Inaddition to fewer bits, for data of the same layer and the same type ina neural network, such as all weight data of a first convolutionallayer, the present disclosure further sets a flag bit, which is thepoint location, to mark the position of the decimal point. In this way,the precision of a data representation and the representable data rangemay be adjusted according to the distribution of actual data.

A floating point number may be represented in 32 bits. The presentdisclosure uses a floating point number to realize a representation. Inthis way, bits of a numerical value may be reduced, less data may needto be transferred, and data of computations may be reduced.

Specifically, input data is shown by FIG. 3c (N samples, each sample hasC channels, and a feature map of each channel has a height of H and awidth of W), and a weight, which is a convolution kernel, is shown byFIG. 3d (with M convolution kernels, and each convolution kernel has Cchannels with a height being KH and a width being KW). For the N samplesof the input data, rules for convolution computations are the same.Below is an explanation of a process of performing a convolutioncomputation on a sample. Each of the M convolution kernels may besubject to the same computation on a sample, each convolution kernel mayobtain a plane feature map by computations, and the NI convolutionkernels may obtain M plane feature maps by computations (for a sample,output of convolution is M feature maps), for a convolution kernel, aninner product computation may be performed on each plane of a sample,and the convolution kernel may slide in a direction of H and a directionof W, for instance, FIG. 3e is a figure showing that a convolutionkernel performs an inner product computation at a position at lowerright corner of a sample of input data; FIG. 3f shows a position ofconvolution sliding leftwards for one grid, and FIG. 3g shows a positionof convolution sliding upwards for one grid.

If a first computation is a convolution computation, the input data maybe convolution input data, and the weight data may be a convolutionkernel. Accordingly, a first complexity may be calculated as firstcomplexity=α*C*kWkW*M*N*W*C*H, where α is a convolution coefficientgreater than 1; C, kH, kW, and M are values of four dimensions of theconvolution kernel, and N, W, C, and H are values of four dimensions ofthe convolution input data. If the first complexity is greater than apreset threshold, the main processing circuit may determine whether theconvolution input data and the convolution kernel are floating pointdata. If the convolution input data and the convolution kernel arefloating point data, the main processing circuit may convert theconvolution input data and the convolution kernel into fixed point data,and then perform convolution computations on the convolution input dataand the convolution kernel according to the fixed point data type.

Specifically, the convolution may be processed by using the chipstructure shown in FIG. 1a or FIG. 3d . When the first complexity isgreater than the preset threshold, the data type conversion circuit ofthe main processing circuit (or may be referred to as main unit) mayconvert data in some or all convolution kernels of the weight to fixedpoint data, the control circuit of the main processing circuit maytransfer data of some or all convolution kernels of the weight to basicprocessing circuits (or may be referred to as basic unit) that aredirectly connected to the main processing circuit via horizontal datainput interfaces (for instance, gray vertical data pathways at the topof FIG. 1f ). I. In an alternative example, each time, the controlcircuit of the main processing circuit may transfer a number or somenumbers of data in a convolution kernel of the weight to a basicprocessing circuit, for instance, for a basic processing circuit, a1^(st) number in a 3^(rd) row may be transferred at a 1^(st) time, a2^(nd) number in the 3^(rd) row may be transferred at a 2^(nd) time, a3^(rd) number in the 3^(rd) row may be transferred at a 3^(rd) time, . .. , or first two numbers in a 3^(rd) row may be transferred at a 1^(st)time, a 3^(rd) number and a 4^(th) number in the 3^(rd) row may betransferred at a 2^(nd) time, a 5^(th) number and a 6^(th) number in the3^(rd) row may be transferred at a 3^(rd) time, . . . . Anotheralternative example may be that, each time, the control circuit of themain processing circuit may transfer a number or some numbers of data ofsome convolution kernels of the weight to a basic processing circuit,for instance, for a basic processing circuit, 1^(st) numbers in a3^(rd), 4^(th) and 5^(th) rows may be transferred at a 1^(st) time,2^(nd) numbers in the 3^(rd), 4^(th) and 5^(th) rows may be transferredat a 2^(nd) time, 3^(rd) numbers in the 3^(rd), 4^(th) and 5^(th) rowsmay be transferred at a 3^(rd) time, . . . , or first two numbers in a3^(rd), 4^(th) and 5^(th) rows may be transferred at a 1^(st) time,3^(rd) numbers and 4^(th) numbers in the 3^(rd), 4^(th) and 5^(th) rowsmay be transferred at a 2^(nd) time, 5^(th) numbers and 6^(th) numbersin the 3^(rd), 4^(th) and 5^(th) rows may be transferred at a 3^(rd)time, . . . .

The control circuit of the main processing circuit may divide input dataaccording to positions of convolution, and may transfer data of some orall positions of convolution in the input data to the basic processingcircuits that are directly connected to the main processing circuit viathe vertical data input interfaces (for instance, the gray horizontaldata pathways on the left of the basic processing circuit array shown inFIG. 1f ). In an alternative example, each time, the control circuit ofthe main processing circuit may transfer a number or some numbers ofdata of a position of convolution in the input data to a basicprocessing circuit; for instance, for a basic processing circuit, a1^(st) number in a 3^(rd) column may be transferred at a 1^(st) time, a2^(nd) number in the 3^(rd) column may be transferred at a 2^(nd) time,a 3^(rd) number in the 3^(rd) column may be transferred at a 3^(rd)time, . . . , or first two numbers in a 3^(rd) column may be transferredat a 1^(st) time, a 3^(rd) number and a 4^(th) number in the 3^(rd)column may be transferred at a 2^(nd) time, a 5^(th) number and a 6^(th)number in the 3^(rd) column may be transferred at a 3^(rd) time, . . . ;another case in an alternative example may be that, each time, thecontrol circuit of the main processing circuit may transfer a number orsome numbers of data of some positions of convolution in the input datato a basic processing circuit; for instance, for a basic processingcircuit, 1^(st) numbers in a 3^(rd), 4^(th) and 5^(th) columns may betransferred at 1^(st) time, 2^(nd) numbers in the 3^(rd), 4^(th) and5^(th) columns may be transferred at a 2^(nd) time, 3^(rd) numbers inthe 3^(rd), 4^(th) and 5^(th) columns may be transferred at a 3^(rd)time, . . . , or first two numbers in a 3^(rd), 4^(th) and 5^(th)columns may be transferred at a P^(t) time, 3^(rd) numbers and 4^(th)numbers in the 3^(rd), 4^(th) and 5^(th) columns may be transferred at a2^(nd) time, 5^(th) numbers and 6^(th) numbers in the 3^(rd), 4^(th) and5^(th) columns may be transferred at a 3^(rd) time.

After the basic processing circuit receives the data of the weight, thebasic processing circuit may transfer the data to a subsequent basicprocessing circuit that is connected to the basic processing circuit viaa horizontal data output interface of the basic processing circuit (forinstance, horizontal data pathways filled in white at the center of thebasic processing circuit array shown in FIG. 1f ); after the basicprocessing circuit receives the input data, the basic processing circuitmay transfer the data to a subsequent basic processing circuit that isconnected to the basic processing circuit via a vertical data outputinterface of the basic processing circuit (for instance, vertical datapathways filled in white at the center of the basic processing circuitarray shown in FIG. 1f ); furthermore, each basic processing circuitperforms computations on received data. In an alternative example, eachtime, the basic processing circuit may perform multiplication of one ora plurality of groups of two data, then accumulate a result in theregister and/or on-chip cache. In an alternative example, each time, thebasic processing circuit may compute an inner product of one or aplurality of groups of two vectors, then accumulate a result in theregister and/or on-chip cache; after the basic processing circuitobtains a result by computing, the basic processing circuit may outputthe result through the data output interface. In an alternative example,the computation result may be a final result or an intermediate resultof an inner product computation; specifically, if the basic processingcircuit has an output interface that is directly connected to the mainprocessing circuit, the basic processing circuit may output the resultvia the interface, if no, the basic processing circuit may output theresult towards a basic processing circuit that can output to the mainprocessing circuit directly (for instance, in FIG. 1f , basic processingcircuits at a bottom row can transfer results to the main processingcircuit directly, and other basic processing circuits may transferresults downwards via vertical output interfaces).

After the basic processing circuit receives a computation result fromanother basic processing circuit, the basic processing circuit maytransfer the data to yet another basic processing circuit that isconnected to the basic processing circuit or to the main processing.circuit; specifically, the basic processing circuit may output a resulttowards a direction to the main processing circuit (for instance, basicprocessing circuits at a bottom row can transfer results to the mainprocessing circuit directly, and other basic processing circuits maytransfer results downwards via vertical output interfaces); and the mainprocessing circuit may receive an inner product computation resulttransferred by each basic processing circuit to obtain an output result.

Referring to FIG. 2e , which shows a matrix-multiply-matrix computation,the first computation may be: a matrix-multiply-matrix computation,where the input data may be a first matrix in the matrix-multiply-matrixcomputation, and the weight data may be a second matrix in thematrix-multiply-matrix computation. Accordingly, the first complexitymay be calculated as first complexity=β*F*G*E*F, where β is a matrixcoefficient greater than or equal to 1, F and G are row and columnvalues of the first matrix, and E and F are row and column values of thesecond matrix. If the first complexity is greater than the presetthreshold, the main processing circuit may determine whether the firstmatrix and the second matrix are floating point data if the first matrixand the second matrix are floating point data, the main processingcircuit may convert the first matrix and the second matrix into fixedpoint data, and then perform a matrix-multiply-matrix computation on thefirst matrix and the second matrix according to the fixed point datatype.

FIG. 4e is a flow chart of using the apparatus of FIG. 1e to perform amatrix-multiply-matrix computation. Below is a description of performingmultiplication of a matrix S with a size of M rows and L columns and amatrix P with a size of L rows and N columns, where each row of thematrix S is as long as each column of the matrix P. As shown in FIG. 3f, the neural network computing apparatus has K basic processingcircuits. The method may include: S401 b, if the first complexity isgreater than the preset threshold, converting, by the main processingcircuit, the matrix S and the matrix P into fixed point data;distributing; by, the control circuit of the main processing circuit,data of each row in the matrix S to one of the K basic processingcircuits; storing, by the basic processing circuit, the received data inthe on-chip cache and/or register. Specifically, the data may betransferred to basic processing circuits that are directly connected tothe main processing circuit.

As an alternative example, M is the count of rows of the matrix S. ifM>=K, the control circuit of the main processing circuit may distributea row of the matrix S to M basic processing circuits respectively; andas an alternative example, M is the count of rows of the matrix S, ifM>K, the control circuit of the main processing circuit may distributedata of one or a plurality of rows of the matrix S to each basicprocessing circuits respectively.

In a case where Mi rows of the matrix S are distributed to an i^(th)basic processing circuit, a set of the Mi rows can be referred to as Ai.FIG. 3g shows a computation to be performed by the i^(th) basicprocessing circuit.

As an alternative example, in each of the basic processing circuits, forinstance, in the i^(th) basic processing circuit: the matrix Aidistributed by the main processing circuit may be received and stored inthe register and/or on-chip cache of the i^(th) basic processingcircuit. Technical effects of the example include that data transferredafterwards may be reduced, the computational efficiency may be improved,and the power consumption may be reduced.

The method may include S402 b: transferring by means of broadcasting, bythe control circuit of the main processing circuit, each part of thematrix P to each basic processing circuit;

As an alternative example, each part of the matrix P may be broadcastfor only once to the register or on-chip cache of each basic processingcircuit, the i^(th) basic processing circuit may fully reuse data of thematrix P which is obtained at this time to complete an inner productcomputation corresponding to each row of the matrix Ai. The reusingmentioned in the example may be repeatedly using data by the basicprocessing circuits during computation, for instance, reusing data ofthe matrix P may be using the data of the matrix P for a plurality oftimes.

As an alternative example, the control circuit of the main processingcircuit may sequentially broadcast each part of the matrix P to theregister or on-chip cache of each basic processing circuit, the i^(th)basic processing circuit may not reuse the data of the matrix P which isobtained at each time, and may complete an inner product computationcorresponding to each row of the matrix Ai at different times; as analternative example, the control circuit of the main processing circuitmay sequentially broadcast each part of the matrix P to the register oron-chip cache of each basic processing circuit, the i^(th) basicprocessing circuit may partially reuse the data of the matrix P which isobtained at each time to complete an inner product computationcorresponding to each row of the matrix Ai; and in an alternativeexample, each of the basic processing circuits, for instance, the i^(th)basic processing circuit, may compute an inner product of the data ofthe matrix Ai and the data of the matrix P.

The method may further include S4O3 b: accumulating, by the accumulatorcircuit of each of the basic processing circuits, a result of the innerproduct computation, and transferring an accumulation result to the mainprocessing circuit.

As an alternative example, the basic processing circuits may transfer apartial sum obtained from each inner product computation to the mainprocessing circuit for accumulating. In an alternative example, apartial sum obtained from the inner product computation performed eachtime by the basic processing circuits may be stored in the on-chipcaching circuit and/or the register of the basic processing circuits,and transferred to the main processing circuit after the accumulationends; and as an alternative example, a partial sum obtained from theinner product computation performed each time by the basic processingcircuits may also, in some cases, be stored in the on-chip cachingcircuit and/or the register of the basic processing circuits foraccumulating, and in some cases, be transferred to the main processingcircuit for accumulating, then be transferred to the main processingcircuit after the accumulation ends.

FIG. 2d is a schematic diagram of a matrix-multiply-vector computation.The first computation may be: a matrix-multiply-vector computation,where the input data may be a first matrix in the matrix-multiply-vectorcomputation, and the weight data may be a vector in thematrix-multiply-vector computation. Accordingly, the first complexitymay be calculated as first complexity=β*PG*F, where β is a matrixcoefficient greater than or equal to 1, F and G are row and columnvalues of the first matrix, and F is a column value of the vector. Ifthe first complexity is greater than the preset threshold, the mainprocessing circuit may determine whether the first matrix and the vectorare floating point data. If the first matrix and the vector are floatingpoint data, the main processing circuit may convert the first matrix andthe vector into fixed point data, and then perform amatrix-multiply-vector computation on the first matrix and the vectoraccording to the fixed point data type.

FIG. 4f shows an implementation method of matrix-multiply-vector, whichmay include: S401, converting, by the data type conversion circuit ofthe main processing circuit, data of each row in the matrix S into fixedpoint data; distributing, by the control circuit of the main processingcircuit, the fixed point data to one of the K basic processing circuits;and storing, by the basic processing circuit, the received data in theon-chip cache and/or register of the basic processing circuit; as analternative example, M is the count of rows of the matrix S, if M>=K,the control circuit of the main processing circuit may distribute a rowof the matrix S to the K basic processing circuits respectively; and asan alternative example, M is the count of rows of the matrix S, if M>K,the control circuit of the main processing circuit may distribute dataof one or a plurality of rows of the matrix S to each basic processingcircuits respectively.

A set of rows of the matrix S that are distributed to an i^(th) basicprocessing circuit may be referred to as Ai, which has Mi rows in total.FIG. 3e shows a computation to be performed by the i^(th) basicprocessing circuit.

As an alternative example, for each basic processing circuit, such as inthe i^(th) basic processing circuit, the received data such as a matrixAi which is transferred by means of distributing may be stored in theregister and/or on-chip cache. Technical effects of the example includethat data that are transferred afterwards by means of distributing maybe reduced, the computational efficiency may be improved, and the powerconsumption may be reduced.

The method may further include S402: converting, by the data typeconversion data type conversion circuit of the main processing circuit,the vector P into fixed point data, and transferring by means ofbroadcasting, by the control circuit of the main processing circuit,each part of the vector P having a fixed point type to the K basicprocessing circuits; as an alternative example, the control circuit ofthe main processing circuit may broadcast each part of the vector P foronly once to the register or on-chip cache of each basic processingcircuit, the i^(th) basic processing circuit may fully reuse data of thevector P which is obtained at this time to complete an inner productcomputation corresponding to each row of the matrix AL Technical effectsof the example include that the data of the vector P which arerepeatedly transferred from the main processing circuit to the basicprocessing circuits may be reduced, the execution efficiency may beimproved, and the power consumption for transferring may be reduced.

As an alternative example, the control circuit of the main processingcircuit may sequentially broadcast each part of the vector P to theregister or on-chip cache of each basic processing circuit, the basicprocessing circuit may not reuse data of the vector P which is obtainedat each time, and may complete an inner product computationcorresponding to each row of the matrix Ai at different times. Technicaleffects of the example include that the data of the vector P which istransferred at a single time in the basic processing circuits may bereduced, the capacity of the cache and/or register of the basicprocessing circuits may be reduced, the execution efficiency may beimproved, the power consumption of transferring may be reduced, and thecosts may be reduced.

As an alternative example, the control circuit of the main processingcircuit may sequentially broadcast each part of the vector P to theregister or on-chip cache of each basic processing circuit, the basicprocessing circuit may partly reuse data of the vector P which isobtained at each time to complete an inner product computationcorresponding to each row of the matrix Ai. Technical effects of theexample include that the data transferred from the main processingcircuit to the basic processing circuits may be reduced, the data thatare transferred within the basic processing circuits may be reduced, theexecution efficiency may be improved, and the power consumption oftransferring may be reduced.

The method may further include S403: computing, by the inner productcomputing unit circuit of the K basic processing circuits, an innerproduct of the matrix S and the vector P, for instance, computing, bythe i^(th) basic processing circuit, an inner product of the data ofmatrix Ai and the data of the vector P.

The method may further include S404: accumulating, by the accumulatorcircuit of the K basic processing circuits, a result of the innerproduct computation to obtain an accumulation result, and transferringthe accumulation result in a fixed point type to the main processingcircuit.

As an alternative example, a partial sum obtained from the inner productcomputation performed each time by the basic processing circuits may betransferred to the main processing circuit for accumulating (the partialsum refers to part of the accumulation result, for instance, if theaccumulation result is F1*G1+F2*G2+F3*G3+F4*G4+F5*G5, the partial summay be the value of F1*G1+F2*G2+F3*G3). Technical effects of the exampleinclude that computations performed within the basic processing circuitsmay be reduced, and the computational efficiency of the basic processingcircuits may be improved.

In an alternative example, a partial sum obtained from the inner productcomputation performed each time by the basic processing circuits may bestored in the on-chip caching circuit and/or the register of the basicprocessing circuits, and transferred to the main processing circuitafter the accumulation ends. Technical effects of the example includethat data transferred between the basic processing circuits and the mainprocessing circuit may be reduced, the computational efficiency may beimproved, and the power consumption of data transferring may be reduced.

As an alternative example, a partial sum obtained from the inner productcomputation performed each time by the basic processing circuits mayalso, in some cases, be stored in the on-chip caching circuit and/or theregister of the basic processing circuits for accumulating, and in somecases, be transferred to the main processing circuit for accumulating,then be transferred to the main processing circuit after theaccumulation ends. Technical effects of the example include that datatransferred between the basic processing circuits and the mainprocessing circuits may be reduced, the computational efficiency may beimproved, the power consumption of data transferring may be reduced,computations performed within the basic processing circuits may bereduced, and the computational efficiency of the basic processingcircuits may be improved.

The present disclosure further provides an integrated circuit chipapparatus which may be configured to perform a forward computation of aneural network, where the neural network may include a plurality oflayers, and the apparatus may include a processing circuit and anexternal interface; the external interface may be configured to receivea first operation instruction; and the processing circuit may beconfigured to parse the first operation instruction to obtain a firstcomputation and corresponding input data and weight data of the firstoperation instruction which are included in an i^(th) layer of theforward computation, where i may be 1, if 1 is 1, the input data may beoriginal input data, and when i is greater than or equal to 2, the inputdata can be output data of a previous layer, such as output data ofi−1^(th) layer.

The processing circuit may further be configured to determine a firstcomplexity of a first computation according to the input data, theweight data, and the first computation, and determine a first data typeof the input data and the weight data when performing the firstcomputation according to the first complexity, where the first data typemay include: a floating point type or a fixed point type.

The processing circuit may further be configured to perform the firstcomputation included in an i^(th) layer of the forward computation onthe input data and the weight data according to the first data type.

FIG. 1h is a structural diagram of integrated circuit chip apparatus. Asshown in FIG. 1a , the chip apparatus may include a main processingcircuit, a basic processing circuit, and a branch processing circuit.Specifically, the integrated circuit chip apparatus may include: a mainprocessing circuit, k branch circuits (as shown in FIG. 1h , k=4, in incertain applications, k may be other numerical value such as 8 and 16),and k groups of basic processing circuits. Where the main processingcircuit may be connected to the k branch circuits respectively, each ofthe k branch circuits may correspond to each group of the k groups ofbasic processing circuits, and one group of basic processing circuitsmay include at least one basic processing circuit; as shown in FIG. 1h ,the branch circuit may include: a data type conversion circuit that maybe configured to convert data between a floating point data type and afixed point data type; the main processing circuit may be configured toperform neural network computations in series, and transfer data to thek branch circuits that are connected to the main processing circuit; thek branch circuits may be configured to forward the data transferredbetween the main processing circuit and the k groups of basic processingcircuits, and determine Whether to turn on the data type conversioncircuits according to computations of the data transferred; the datatype conversion circuit may be configured to convert the datatransferred; and the k basic processing circuits may be configured toperform neural network computations in parallel according to the datatransferred or converted data transferred, and transfer a computationresult to the main processing circuit.

In an alternative example, as shown in FIG. 1a , the main processingcircuit may also include: a data type conversion circuit, where the datatype conversion circuit may be configured to convert received ortransferred data from floating point data to fixed point data. Ofcourse, in in certain applications, the data type conversion circuit mayalso convert fixed point data into floating point data. The presentdisclosure does not restrict a form of the data type conversion circuit.

Referring to apparatus shown in FIG. 1i , in the apparatus, a branchprocessing circuit may be connected to a main processing circuitseparately. The apparatus shown in FIG. 1i may include a main processingcircuit and N basic processing circuits, where the main processingcircuit (whose structure is shown in FIG. 1c ) may be connected to the Nbasic processing circuits directly or indirectly. If the main processingcircuit is connected to the N basic processing circuits indirectly, analternative connection scheme is shown in FIG. 1h , where N/4 branchprocessing circuits may be included, and each branch processing circuitmay be connected to four basic processing circuits respectively.Regarding circuits that are included in the main processing circuit andthe N basic processing circuits, a description of them can be seen inthe description of FIG. 1a , which is omitted here. It should beexplained that the basic processing circuits may also be arranged insidethe branch processing circuits, and besides, a count of basic processingcircuits that are connected to each branch processing circuit may not berestricted to 4. Manufacturers can set the count according to actualneeds. The main processing circuit and/or the N basic processingcircuits may all include a data type conversion circuit. Specifically,it may be the main processing circuit that includes a data typeconversion circuit, and may also be the N basic processing circuits orsome of the basic processing circuits that include a data typeconversion circuit, and may further be the main processing circuit andthe N basic processing circuits that include a data type conversioncircuit. The main processing circuit may dynamically allocate an entityto perform a step of data type conversion according to a neural networkcomputation instruction. Specifically, the main processing circuit maydetermine whether to turn on the data type conversion circuit to performthe step of data type conversion on received data according to itsloads. Specifically, a value of the loads may be set as a plurality ofranges, where each range corresponds to a different entity forperforming the step of data type conversion. Taking three ranges as aninstance, range 1 corresponds to light loads, where the main processingcircuit may perform the step of data type conversion alone; range 2corresponds to loads between range 1 and range 3, where the mainprocessing circuit or the N basic processing circuits may perform thestep of data type conversion together; and range 3 corresponds to heavyloads, where the N basic processing circuits may perform the step ofdata type conversion.

Referring to a structure shown in FIG. 1j , the structure may include amain processing circuit (capable of performing vector operation) and aplurality of basic processing circuits (capable of performing innerproduct operation). A technical effect of the combination is that theapparatus can not only use the basic processing circuits to performmatrix and vector multiplication, but can also use the main processingcircuit to perform any other vector computations, so that the apparatusmay complete more computations faster with a configuration where alimited count of hardware circuits are included. The combination mayreduce a count of times that data is transferred with the outside of theapparatus, improve computational efficiency, and reduce powerconsumption. Besides, in the chip, a data type conversion circuit may bearranged in the basic processing circuits and/or the main processingcircuit, so that floating point data may be converted into fixed pointdata when a neural network computation is being performed, and fixedpoint data may also be converted into floating point data. In addition,the chip may also dynamically allocate a circuit to perform data typeconversion according to the amount of computation (loads) of eachcircuit (mainly the main processing circuit and the basic processingcircuits), which may reduce complex procedures of data computation andreduce power consumption. By dynamically allocating a circuit to performdata type conversion, the computational efficiency of the chip may notbe affected. An allocation method may include but is not limited to:load balancing, load minimum allocation, and the like.

Referring to apparatus shown in FIG. 1k , the apparatus does not includeany branch processing circuit. The apparatus in FIG. 1k may include amain processing circuit and N basic processing circuits, where the mainprocessing circuit (whose structure is shown in FIG. 1c ) may beconnected to the N basic processing circuits directly or indirectly. Ifthe main processing circuit is connected to the N basic processingcircuits indirectly, an alternative scheme of connection is shown inFIG. 1j , where N/4 branch processing circuits may be included, and eachbranch processing circuit may be connected to four basic processingcircuits respectively. Regarding circuits that are included in the mainprocessing circuit and the N basic processing circuits, a description ofthem can be seen in the description of FIG. 1a , which is omitted here.It should be explained that the basic processing circuits may also bearranged inside the branch processing circuits, and besides, a count ofbasic processing circuits that are connected to each branch processingcircuit may not be restricted to 4. Manufacturers can set the countaccording to actual needs. The main processing circuit and/or the Nbasic processing circuits may all include a data type conversioncircuit. Specifically, it may be the main processing circuit thatincludes a data type conversion circuit, and may also be the N basicprocessing circuits or some of the basic processing circuits thatinclude a data type conversion circuit, and may further be the mainprocessing circuit and the N basic processing circuits that include adata type conversion circuit. The main processing circuit maydynamically allocate an entity to perform a step of data type conversionaccording to a neural network computation instruction. A method ofallocating an entity to perform a step of data type conversion can beseen in the description of the example shown in FIG. 1 i.

FIG. 11 shows integrated circuit chip apparatus provided by the presentdisclosure. The integrated circuit chip apparatus may include: a mainprocessing circuit and a plurality of basic processing circuits, wherethe plurality of basic processing circuits are arranged in a form ofarray (an m*n array), the value range of m and n is an integer greaterthan or equal to 1, and at least one of in and n is greater than orequal to 2. For the plurality of basic processing circuits that arearranged in the form of a m*n array, each basic processing circuit maybe connected to an adjacent basic processing circuit, and the mainprocessing circuit may be connected to k basic processing circuits ofthe plurality of basic processing circuits, where the k basic processingcircuits may be: n basic processing circuits in a first row, n basicprocessing circuits in an m^(th) row, and/or in basic processingcircuits in a first column. In the integrated circuit chip apparatusshown in FIG. 1l , the main processing circuit and/or the plurality ofbasic processing circuits may include a data type conversion circuit,and specifically, some basic processing circuits of the plurality ofbasic processing circuits may include a data type conversion circuit.For instance, in an alternative example, the k basic processing circuitsmay be configured with a data type conversion circuit. In this way, then basic processing circuits may perform a step of data type conversionon data of the m basic processing circuits of a current column. Thisconfiguration may improve computational efficiency and reduce powerconsumption. For the n basic processing circuits in the first row, sincethey are the first to receive data sent from the main processingcircuit, by converting the received data into fixed point data,computations performed by subsequent basic processing circuits and datatransferred by the subsequent basic processing circuits may be reduced.Similarly, configuring the m basic processing circuits of the firstcolumn with a data type conversion circuit may also have technicaleffects of fewer computations and less power consumption. In addition,according to the structure, the main processing circuit may use adynamic data transferring strategy. For instance, the main processingcircuit may broadcast data to the m basic processing circuits of thefirst column, and distribute data to the n basic processing circuits ofthe first row. A technical effect of the example is that by transferringdifferent data to the basic processing circuits via different data inputports, the basic processing circuit may know the type of data merelyaccording to a receiving port of the data without the need ofdistinguishing the type of the received data.

An example of the present disclosure provides an integrated circuit chipapparatus. The integrated circuit chip apparatus may include a mainprocessing circuit (may also be referred to as a main unit) and aplurality of basic processing circuit (may also be referred to as basicunits). A structure of the example is shown in FIG. 1f , where inside adashed box is an internal structure of the neural network computingapparatus, a gray arrow indicates a data transferring path between themain processing circuit and the basic processing circuits, and anoutlined arrow indicates a data transferring path between the respectivebasic processing circuits (adjacent basic processing circuits) in thebasic processing circuit array. The length and width of the basicprocessing circuit array may be different. In other words, the values ofm and n may be different, and may be the same. The values are notrestricted in the present disclosure.

As shown in FIG. 1m , a step of neural network training may include:performing, by each layer of a (multi-layer) neural network, forwardcomputation subsequently; performing a back computation subsequentlyaccording to a reverse order of the layers to obtain a weight gradient;and updating a weight of the forward computation by using the obtainedweight gradient.

This is a sequential iteration of neural network training, which may beperformed repeatedly (in other words, a plurality times of iterationcomputations) for a plurality of times during an entire trainingprocess.

The present disclosure further provides neural network computingapparatus. The apparatus may include one or a plurality of chips shownin FIG. 1a or FIG. 1b , where the apparatus may be configured to acquiredata to be computed and control information from other processingapparatus, perform specified neural network operations, and transferexecution results to peripheral apparatus through an I/O interface. Theperipheral apparatus may include a camera, a monitor, a mouse, akeyboard, a network card, a WIFI interface, a server, and the like. Whenmore than one chips shown in FIG. 1a or FIG. 1b are included, the chipsmay be connected to and transfer data to each other through a structure,for example, the chips may be interconnected and transfer data via aPCIE bus to support neural network operations with larger scale. In thiscase, the chips as shown in FIG. 1a or FIG. 1b may share the samecontrol system, or have separate control systems. The chips may share amemory, or have their own memories. In addition, an interconnectionmethod of the chips as shown in FIG. 1a or FIG. 1b may be anyinterconnection topology.

The neural network computing apparatus may have good compatibility andmay be connected to various types of servers through a PCIE interface.

The present disclosure also provides a processing apparatus which mayinclude the neural network computing apparatus, a generalinterconnection interface, and other processing apparatus(general-purpose processing apparatus). The neural network computingapparatus may interact with other processing apparatus to performoperations specified by users. FIG. 4c is a schematic diagram of theprocessing apparatus.

The other processing apparatus may include at least one or more of ageneral-purpose/special-purpose processors such as a central processingunit (CPU), a graphics processing unit (GPU), a neural networkprocessor, and the like. The present disclosure does not restrict acount of processors included in the other processing apparatus. Theother processing apparatus may serve as an interface that connects theneural network computing apparatus to external data and control,including data moving, and may perform the basic control such asstarting and stopping the neural network computing apparatus. The otherprocessing apparatus may also cooperate with the neural networkcomputing apparatus to complete computation tasks.

The general interconnection interface may be configured to transfer dataand control instructions between the neural network computing apparatusand the other processing apparatus. The neural network computingapparatus may obtain required input data from the other processingapparatus and write the data in an on-chip storage device of the neuralnetwork computing apparatus. The neural network computing apparatus mayobtain control instructions from the other processing apparatus, andwrite the control instructions in an on-chip control cache of the neuralnetwork computing apparatus. The neural network computing apparatus mayfurther read data stored in a storage module of the neural networkcomputing apparatus and transfer the data to the other processingapparatus.

As shown in FIG. 4d , alternatively, the structure may further includestorage apparatus configured to store required data of a presentcomputing unit/computing apparatus or another computing unit, and isparticularly suitable for a case where data that need to be computedcannot be completely stored in an internal memory of the neural networkcomputing apparatus or another processing apparatus.

The processing apparatus can be used as an SOC (System On Chip) of adevice including a mobile phone, a robot, a drone, a video surveillancedevice, and the like, Which may effectively reduce the core area of acontrol part, increase the processing speed, and reduce the overallpower consumption. In this case, a universal interconnection interfaceof the processing apparatus may be connected to some components of theapparatus. The components may include a camera, a monitor, a mouse, akeyboard, a network card, and a WIFI interface.

The present disclosure provides a neural network processor board cardwhich can be used in various general-purpose or special-purposecomputing system environments or configurations. For instance, personalcomputers, server computers, handheld or portable devices, tabletdevices, smart home, home appliances, multiprocessor systems,microprocessor based systems, robots, programmable consumer electronics,network personal computers, small computers, large computers,distributed computing environments including any of the systems ordevices above, and the like.

FIG. 5c is a structural diagram of a neural network processor board cardaccording to an example of the present disclosure. As shown in FIG. 5c ,the neural network processor board card 10 may include a neural networkchip package structure 11, a first electrical and non-electricalconnection device 12, and a first substrate 13.

The present disclosure does not restrict a structure of the neuralnetwork chip package structure 11. Optionally, as shown in FIG. 5d , theneural network chip package structure 11 may include a neural networkchip 111, a second electrical and non-electrical connection device 112,and a second substrate 113.

The present disclosure does not restrict a form of the neural networkchip 111. The neural network chip 111 may include but is not limited toa neural network wafer integrated with a neural network processor, wherethe wafer may be made of silicon material, germanium material, quantummaterial, or molecular material. In some embodiments, the neural networkwafer may be packaged (for example, a harsh environment), so that mostof the neural network wafer may be wrapped, and leads on the neuralnetwork wafer may be connected to the outside of the packaging structurethrough conductors such as gold wire, which can be used for circuitconnection with an outer layer.

The present disclosure does not restrict a structure of the neuralnetwork chip 111. Alternatively, the apparatus shown in FIG. 1a and FIG.1b may be used as reference.

The present disclosure does not restrict types of the first substrate 13and the second substrate 113. The types of the first substrate and thesecond substrate may be a printed circuit board (PCB) or a printedwiring board (PWB), and may also be another circuit board. The presentdisclosure does not restrict the material that the PCB is made of.

The second substrate 113 of the present disclosure may be used to bearthe neural network chip 111, and the chip package structure obtained byconnecting the neural network chip 111 and the second substrate 113through the second electrical and non-electrical connection device 112is used for protecting the neural network chip 111, so that the neuralnetwork chip package structure 11 and the first substrate 13 can befurther packaged.

The present disclosure does not restrict a manner for packaging and acorresponding structure of the manner for packaging of the secondelectrical and non-electrical connection device 112. An appropriatepackage manner can be selected and be subject to simple improvementaccording to the specific application and different applicationrequirements, such as Flip Chip Ball Grid Array Package (FCBGAP),Low-profile Quad Flat Package (LQFP), Quad Flat Package with Heat Sink(HQFP), Quad Flat Non-lead Package (QFN), or a Fine-Pitch Ball GridPackage (FBGA) and other package manners.

A flip chip may be suitable for a case where the requirement on the areaafter packaging is high or an inductor of a conductive wire and atransmission time of a signal are sensitive. In addition, a packagemanner of wire bonding may be adopted to reduce the cost and increasethe flexibility of the package structure.

Ball Grid Array may provide more leads, and the average wire length ofthe leads is short, which can transfer signals at high speed, where thepackage may be replaced by Pin Grid Array (PGA), Zero Insertion Force(ZIF), Single Edge Contact Connection (SECC), Land Grid Array (LGA), andthe like.

Optionally, the package manner of Flip Chip Ball Grid Array may beadopted to package the neural network chip 111 and the second substrate113. Please refer to FIG. 6a for a schematic diagram of a packagestructure of the neural network chip. As shown in FIG. 6a , the neuralnetwork chip package structure may include a neural network chip 21, apad 22, a ball 23, a second substrate 24, a connection point 25 on thesecond substrate 24, and a lead 26.

The pad 22 is connected to the neural network chip 21, and the ball 23is formed by welding between the pad 22 and the connection point 25 onthe second substrate 24, in this way, the neural network chip 21 and thesecond substrate 24 is connected, thereby realizing the package of theneural network chip 21.

The lead 26 is used to connect an external circuit of the packagestructure (for instance, the first substrate 13 on the neural networkprocessor board card 10) for transferring external data and internaldata, which may facilitate data processing by the neural network chip 21or a corresponding neural network processor of the neural network chip21. A type and quantity of leads are not restricted in the presentdisclosure. Different lead types can be selected according to differentpackaging technologies, and leads can be arranged according to certainrules.

Optionally, the neural network chip package structure may furtherinclude an insulating filler disposed in the gap between the pad 22, theball 23, and the connection point 25 for preventing interference betweenballs.

The material of the insulating filler may be silicon nitride, siliconoxide or silicon oxynitride; and the interference may includeelectromagnetic interference, inductance interference, and the like.

Optionally, the neural network chip package structure may furtherinclude a heat dissipation device for dissipating heat generated duringthe operation of the neural network chip 21. The heat dissipation devicemay be a piece of metal with good thermal conductivity, a heat sink, ora radiator such as a fan.

For instance, as shown in FIG. 6b , the neural network chip packagestructure 11 may include: a neural network chip 21, a pad 22, a ball 23,a second substrate 24, a connection point 25 on the second substrate 24,a lead 26, an insulating filler 27, thermal compound 28, and a tin 29with metal housing. Among them, the thermal compound 28 and the fin 29with metal housing are configured to dissipate the heat generated duringthe operation of the neural network chip 21.

Optionally, the neural network chip package structure 11 may furtherinclude a reinforcing structure, which is connected to the pad 22, andis buried in the ball 23 to enhance the connection strength between theball 23 and the pad 22.

The reinforcing structure may be a metal wire structure or a columnarstructure, which is not restricted herein.

A form of the first electrical and non-electrical device 12 is notrestricted in the present disclosure. Please refer to the description ofthe second electrical and non-electrical device 112. In other words, theneural network chip package structure may be packaged by welding, or byconnecting the second substrate 113 and the first substrate 13 through aconnecting line or by means of plugging, so that the first substrate 13or the neural network chip package structure 11 can be replacedconveniently later.

Optionally, the first substrate 13 may include a memory unit interfacefor expanding storage capacity, such as a Synchronous Dynamic RandomAccess Memory (SDRAM), and a Double Date Rate (DDR) SDRAM, and the like.By expanding the memory, the processing capacity of the neural networkprocessor may be improved.

The first substrate 13 may further include a Peripheral ComponentInterconnect-Express (PCI-E or PCIe) interface, a Small Form-factorPluggable (SFP) interface, and an Ethernet interface, a Controller AreaNetwork (CAN) interface, and the like, which can be used for datatransferring between the package structure and external circuits. Inthis way, the computational speed may be improved, and the operation maybe easier.

The neural network processor is packaged into a neural network chip 111,the neural network chip 111 is packaged into a chip package structure11, and the neural network chip package structure 11 is packaged into aneural network processor board card 10. Data interaction with anexternal circuit (for instance, a computer motherboard) may be performedthrough an interface (slot or ferrule) on the board card, that is, thefunction of the neural network processor may be implemented by using theneural network processor board card 10 directly, which may also protectthe neural network chip 111. In addition, other modules may be added tothe neural network processor board card 10, which may improve theapplication range and computational efficiency of the neural networkprocessor.

An example of the present disclosure provides an electronic deviceincluding the neural network processor board card 10 or the neuralnetwork chip package structure 11.

The electronic device may include a data processing device, a robot, acomputer, a printer, a scanner, a tablet, a smart terminal, a mobilephone, a traffic recorder, a navigator, a sensor, a webcam, a server, acamera, a video camera, a projector, a watch, a headphone, a mobilestorage, a wearable device, a vehicle, a household appliance, and/or amedical equipment.

The vehicle may include an airplane, a ship, and/or a car. The householdelectrical appliance may include a television, an air conditioner, amicrowave oven, a refrigerator, an electric rice cooker, a humidifier, awashing machine, an electric lamp, a gas cooker, and a range hood; andthe medical equipment may include a nuclear magnetic resonancespectrometer, a B-ultrasonic scanner, and/or an electrocardiograph,

The examples further explain the purpose, technical solutions andtechnical effects of the present disclosure. It should be understoodthat the foregoing are merely examples of the present disclosure, andare not intended to limit the present disclosure. Any modification,equivalent substitution, improvement, and the like, to the presentdisclosure within the spirit and principles of the present disclosureshall be included in the protection scope of the present disclosure.

1. A method for performing a neural network computation using anintegrated circuit chip apparatus, wherein the method comprises:receiving an operation instruction; parsing the operation instruction toobtain input data and weight data for a first computation; determining afirst complexity of the first computation according to the input data,the weight data, and characteristics of the first computation;determining a first data type for the input data and the weight data inwhich the first computation is to be performed according to the firstcomplexity, wherein the first data type is a floating point data type ora fixed point data type; and performing the first computation on theinput data and the weight data. in the first data type.
 2. The method ofclaim 1, wherein the determining the first data type further comprises:comparing the first complexity with a preset threshold; if the firstcomplexity is greater than the preset threshold, determining the firstdata type to be the fixed point data type; and if the first complexityis less than or equal to the preset threshold, determining the firstdata type to be the floating point data type.
 3. The method of claim 1,the method further comprises: determining that the input data or theweight data are in a second data type different from the first datatype; and converting the input data or the weight data from the seconddata type into the first data type.
 4. The method of claim 3, whereinthe first data type is the fixed point data type and the second datatype is the floating point data.
 5. The method of claim 1, wherein thefirst computation is a convolution computation, wherein the input datais convolution input data and the weight data is a convolution kernel,wherein the first complexity=α*MH*kW*M*N*W*C*H, wherein a is aconvolution coefficient greater than 1, C, kH, kW, and M are values offour dimensions of the convolution kernel, and N, W, C, and H are valuesof four dimensions of the convolution input data.
 6. The method of claim5, further comprising: determining that the first complexity is greaterthan a preset threshold; determining that the convolution input data orthe convolution kernel are in the floating point data type; convertingthe convolution input data or the convolution kernel into the fixedpoint data type; and performing the convolution computation on theconvolution input data and the convolution kernel in the fixed pointdata type.
 7. The method of claim 1, wherein the first computation is amatrix-multiply-matrix computation, wherein the input data is a firstmatrix in the matrix-multiply-matrix computation and the weight data isa second matrix in the matrix-multiply-matrix computation, wherein thefirst complexity=β*F*G**E*F, wherein β is a matrix coefficient greaterthan or equal to 1, F and G are row and column values of the firstmatrix, and E and F are row and column values of the second matrix. 8.The method of claim 7, the method further comprises: determining thatthe first complexity is greater than a preset threshold; determiningthat the first matrix or the second matrix are in the floating pointdata type; converting the first matrix or the second matrix into thefixed point data type; and performing the matrix-multiply-matrixcomputation on the first matrix and the second matrix in the fixed pointdata type.
 9. The method of claim 1, wherein the first computation is amatrix-multiply-vector computation, wherein the input data is a matrixin the matrix-multiply-vector computation, and. the weight data is avector in the matrix-multiply-vector computation, wherein the firstcomplexity=β*F*G*F, wherein β is a matrix coefficient greater than orequal to 1, F and G are row and column values of the matrix, and F is acolumn value of the vector.
 10. The method of claim 9, the methodfurther comprises: determining that the first complexity is greater thana preset threshold; determining that the matrix or the vector are in thefloating point data type; converting the matrix or the vector intofloating point data; and performing the matrix-multiply-vectorcomputation on the matrix and the vector in the fixed point data type.11. The method of claim 1, wherein the first computation is one of abias computation, a fully connected computation, a GEMM computation, aGEMV computation, or an activation computation.
 12. An integratedcircuit chip apparatus configured to perform a neural networkcomputation, comprising: an external interface configured to receive afirst operation instruction; and a processing circuit configured to:parse the first operation instruction to obtain a first computation tobe performed at a layer of the neural network and corresponding inputdata and weight data for performing the first computation; determine afirst complexity of the first computation according to the input data,the weight data, and characteristics of the first computation; determinea first data type for the input data and the weight data in which thefirst computation is to be performed according to the first complexity,wherein the first data type is a floating point datatype or a fixedpoint data type; and perform the first computation on the input data andthe weight data in the first data type.
 13. The integrated circuit chipapparatus of claim 12, wherein the processing circuit is configured to:compare the first complexity with a preset threshold; if the firstcomplexity is greater than the preset threshold, determine the firstdata type to be the fixed point data type; and if the first complexityis less than or equal to the preset threshold, determine the first datatype to he the floating point data type.
 14. The integrated circuit chipapparatus of claim 12, further comprising a data type conversioncircuit, wherein the processing circuit is further configured todetermine that the input data or the weight data is in a second datatype different from the first data type, and the data type conversioncircuit is configured to convert the input data or the weight data fromthe second data type to the first data type.
 15. The integrated circuitchip apparatus of claim 14, wherein the first data type is the fixedpoint data type and the second data type is the floating point data. 16.The integrated circuit chip apparatus of claim 12, wherein the firstcomputation is a convolution computation, wherein the input data isconvolution input data, and the weight data is a convolution kernel.wherein the processing circuit is configured to compute the firstcomplexity asα*C*kW*kH*M*N*W*C*H, wherein a is a convolution coefficientgreater than 1, C, kH, kW, and M are values of four dimensions of theconvolution kernel, and, N, W, C, and H are values of four dimensions ofthe convolution input data.
 17. The integrated circuit chip apparatus ofclaim 12, wherein the first computation is a matrix-multiply-matrixcomputation, wherein the input data is a first matrix in thematrix-multiply-matrix computation, and the weight data is a secondmatrix in the matrix-multiply-matrix computation, wherein the processingcircuit is configured to compute the first complexity as β*F*G*E*F,wherein β is a matrix coefficient greater than or equal to 1, F and Gare row and column values of the first matrix, and E and F are row andcolumn values of the second matrix.
 18. The integrated circuit chipapparatus of claim 12, wherein the first computation is amatrix-multiply-vector computation, wherein the input data is a matrixin the matrix-multiply-vector computation, and the weight data is avector in the matrix-multiply-vector computation, wherein the processingcircuit is configured to compute the first complexity as β*F*G*F,wherein β is a matrix coefficient greater than or equal to 1, F and Gare row and column values of the matrix, and F is a column value of thevector.
 19. The integrated chip circuit apparatus of claim
 12. whereinthe first computation includes one or more of a bias computation, afully connected computation, a GEMM computation, a GEMV computation, oran activation computation.
 20. A processing apparatus, comprising: aneural network computing apparatus configured to perform a neuralnetwork computation of a neural network; a general interconnectioninterface; and a general-purpose processing apparatus connected to theneural network computing apparatus via the general interconnectioninterface, wherein the neural network computation apparatus isconfigured to: receive input data and weight data for performing a firstcomputation; determine a first complexity of the first computationaccording to the input data, the weight data, and characteristics of thefirst computation; determine a first data type for the input data andthe weight data in which the first computation is to be performedaccording to the first complexity, wherein the first data type is afloating point data type or a fixed point data type; and perform thefirst computation on the input data and the weight data in the firstdata type.